Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/stream_core_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

- Fixed `StreamTextInput` ignoring typed text after the widgets around it, such
as `leading` and `trailing`, changed while it had focus.
- Fixed `StreamSnackbarHost` and `StreamSnackbarPopup` throwing in debug when
they mount with a snackbar already queued on their messenger, for example
after the widget holding them is rebuilt.

## 0.5.3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,12 @@ class _SnackbarStageState extends State<_SnackbarStage> with SingleTickerProvide

void _onControllerChanged() => _syncWithController();

// No dependency on MediaQuery: the first read can come from initState.
bool get _accessibleNavigation {
final mediaQuery = context.getInheritedWidgetOfExactType<MediaQuery>();
return mediaQuery?.data.accessibleNavigation ?? false;
}

void _syncWithController() {
final next = widget.messenger._queue.isEmpty ? null : widget.messenger._queue.first;

Expand All @@ -756,7 +762,7 @@ class _SnackbarStageState extends State<_SnackbarStage> with SingleTickerProvide
_animation.value = 0;
setState(() {});
if (next != null) {
if (MediaQuery.accessibleNavigationOf(context)) {
if (_accessibleNavigation) {
_animation.value = 1;
} else {
_animation.forward(from: 0);
Expand Down Expand Up @@ -786,7 +792,7 @@ class _SnackbarStageState extends State<_SnackbarStage> with SingleTickerProvide
final messenger = widget.messenger;
_exiting = true;
_timer?.cancel();
if (MediaQuery.accessibleNavigationOf(context)) {
if (_accessibleNavigation) {
_animation.value = 0;
} else {
await _animation.reverse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,29 @@ void main() {

expect(find.text('Auto-managed'), findsOneWidget);
});

testWidgets('shows a snackbar queued before it mounts', (tester) async {
final messenger = StreamSnackbarMessenger();
addTearDown(messenger.dispose);

messenger.show(StreamSnackbar(message: const Text('Queued')));

await tester.pumpWidget(
MaterialApp(
theme: ThemeData(extensions: [StreamTheme.light()]),
home: Center(
child: StreamSnackbarPopup.withState(
messenger: messenger,
child: const SizedBox(width: 200, height: 60),
),
),
),
);
await tester.pump(const Duration(milliseconds: 300));

expect(tester.takeException(), isNull);
expect(find.text('Queued'), findsOneWidget);
});
});

group('accessibleNavigation', () {
Expand Down Expand Up @@ -893,6 +916,22 @@ void main() {
expect(fadeOf(tester).opacity.value, equals(1.0));
});

testWidgets('on — a snackbar queued before the host mounts skips animation', (tester) async {
tester.platformDispatcher.accessibilityFeaturesTestValue = const FakeAccessibilityFeatures(
accessibleNavigation: true,
);
addTearDown(tester.platformDispatcher.clearAccessibilityFeaturesTestValue);

final messenger = StreamSnackbarMessenger();
addTearDown(messenger.dispose);

messenger.show(StreamSnackbar(message: const Text('Queued')));
await tester.pumpWidget(hostScaffold(messenger));

expect(tester.takeException(), isNull);
expect(fadeOf(tester).opacity.value, equals(1.0));
});

testWidgets('on — exit skips animation and resolves controller after one frame', (tester) async {
tester.platformDispatcher.accessibilityFeaturesTestValue = const FakeAccessibilityFeatures(
accessibleNavigation: true,
Expand Down
Loading