You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Situation
I currently have a flushbar with a duration: const Duration(seconds: 2) that gets shown when a native callback happens. This is how I am calling it
Question
Is there a way I can detect the flushbar in a widget test??
My current tests can not find it and I am guessing it is because the flushbar is only visible for a short time.
What I have tried
I have tried both expect(...) and expectLater(...) in various orders before and after my mock native call in my tests. I have been looking for the Flushbar widget itself as well as the text it displays without success. Also the onStatusChanged prints are showing for appearing and dismissed but NOT for show nor hiding in my test but work fine in my app. Any advice is much appreciated.
The text was updated successfully, but these errors were encountered:
This is my workaround. I also struggled a lot with this. Hope it helps someone.
First, wrap your test in tester.runAsync(). Then, use await tester.pump() to trigger a frame before looking for the Widget. Finally, use the text in the Flushbar to detect it.
testWidgets(
'show a Flushbar with error message',
(tester) async {
await tester.runAsync(() async {
await tester.pumpWidget(...);
await tester.pump();
final errorMessage = find.text('An error occurred.');
expect(errorMessage, findsOneWidget);
});
},
);
Situation
I currently have a flushbar with a
duration: const Duration(seconds: 2)
that gets shown when a native callback happens. This is how I am calling itso it shows for the 2 seconds then disappears.
Question
Is there a way I can detect the flushbar in a widget test??
My current tests can not find it and I am guessing it is because the flushbar is only visible for a short time.
What I have tried
I have tried both
expect(...)
andexpectLater(...)
in various orders before and after my mock native call in my tests. I have been looking for theFlushbar
widget itself as well as the text it displays without success. Also theonStatusChanged
prints are showing forappearing
anddismissed
but NOT forshow
norhiding
in my test but work fine in my app. Any advice is much appreciated.The text was updated successfully, but these errors were encountered: