framePolicy property
Whether to have pump with a duration only pump a single frame (as would happen in a normal test environment using AutomatedTestWidgetsFlutterBinding), or whether to instead pump every frame that the system requests during any asynchronous pause in the test (as would normally happen when running an application with WidgetsFlutterBinding).
-
LiveTestWidgetsFlutterBindingFramePolicy.fadePointers is the default behavior, which is to only pump once, except when there has been some activity with TestPointers, in which case those are shown and may pump additional frames.
-
LiveTestWidgetsFlutterBindingFramePolicy.onlyPumps is the strictest behavior, which is to only pump once. This most closely matches the AutomatedTestWidgetsFlutterBinding (
flutter test
) behavior. -
LiveTestWidgetsFlutterBindingFramePolicy.fullyLive allows all frame requests from the engine to be serviced, even those the test did not explicitly pump.
-
LiveTestWidgetsFlutterBindingFramePolicy.benchmark allows all frame requests from the engine to be serviced, and allows all frame requests that are artificially triggered to be serviced, but prevents the framework from requesting any frames from the engine itself. The SchedulerBinding.hasScheduledFrame property will never be true in this mode. This can cause unexpected effects. For instance, WidgetTester.pumpAndSettle does not function in this mode, as it relies on the SchedulerBinding.hasScheduledFrame property to determine when the application has "settled".
Setting this to anything other than
LiveTestWidgetsFlutterBindingFramePolicy.onlyPumps means pumping extra
frames, which might involve calling builders more, or calling paint
callbacks more, etc, which might interfere with the test. If you know your
test file wouldn't be affected by this, you can set it to
LiveTestWidgetsFlutterBindingFramePolicy.fullyLive persistently in that
particular test file. To set this to
LiveTestWidgetsFlutterBindingFramePolicy.fullyLive while still allowing
the test file to work as a normal test, add the following code to your
test file at the top of your void main() { }
function, before calls to
testWidgets:
TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
if (binding is LiveTestWidgetsFlutterBinding)
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
Implementation
LiveTestWidgetsFlutterBindingFramePolicy framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fadePointers