pumpWidget method

Future<void> pumpWidget (Widget widget, [ Duration duration, EnginePhase phase = EnginePhase.sendSemanticsUpdate ])

Renders the UI from the given widget.

Calls runApp with the given widget, then triggers a frame and flushes microtasks, by calling pump with the same duration (if any). The supplied EnginePhase is the final phase reached during the pump pass; if not supplied, the whole pass is executed.

Subsequent calls to this is different from pump in that it forces a full rebuild of the tree, even if widget is the same as the previous call. pump will only rebuild the widgets that have changed.

See also LiveTestWidgetsFlutterBindingFramePolicy, which affects how this method works when the test is run with flutter run.

Implementation

Future<void> pumpWidget(Widget widget, [
  Duration duration,
  EnginePhase phase = EnginePhase.sendSemanticsUpdate,
]) {
  return TestAsyncUtils.guard<void>(() {
    binding.attachRootWidget(widget);
    binding.scheduleFrame();
    return binding.pump(duration, phase);
  });
}