pump method

  1. @override
Future<void> pump (
  1. [Duration duration,
  2. EnginePhase newPhase = EnginePhase.sendSemanticsUpdate]
)
override

Triggers a frame sequence (build/layout/paint/etc), then flushes microtasks.

If duration is set, then advances the clock by that much first. Doing this flushes microtasks.

The supplied EnginePhase is the final phase reached during the pump pass; if not supplied, the whole pass is executed.

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

Implementation

@override
Future<void> pump([ Duration duration, EnginePhase newPhase = EnginePhase.sendSemanticsUpdate ]) {
  return TestAsyncUtils.guard<void>(() {
    assert(inTest);
    assert(_clock != null);
    if (duration != null)
      _currentFakeAsync.elapse(duration);
    _phase = newPhase;
    if (hasScheduledFrame) {
      addTime(const Duration(milliseconds: 500));
      _currentFakeAsync.flushMicrotasks();
      handleBeginFrame(Duration(
        milliseconds: _clock.now().millisecondsSinceEpoch,
      ));
      _currentFakeAsync.flushMicrotasks();
      handleDrawFrame();
    }
    _currentFakeAsync.flushMicrotasks();
    return Future<void>.value();
  });
}