I'm trying to do a widget test in flutter to one widget which uses WidgetsBinding.instance.addPostFrameCallback() to show a dialog at the very beggining of the widget lifecycle.
The widget works fine, but I cannot figure out how to do a widget test, because the very first expect() of the test is executed before this post frame is triggered.
Anyway to "tell" the test to wait until all the post frames are dispatched?
PD: tester.pump(), tester.pumpAndSettle(), etc. are not working.
To locate widgets in a test environment, use the Finder classes. While it's possible to write your own Finder classes, it's generally more convenient to locate widgets using the tools provided by the flutter_test package.
But what do you know... suddenly it popped up:
tester.binding.scheduleWarmUpFrame();
Run that :-)
Taken from here: https://chromium.googlesource.com/external/github.com/flutter/flutter/+/v0.9.2/packages/flutter/test/widgets/binding_test.dart
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With