Future<int> pumpUntilNoTransientCallbacks([@required Duration duration, EnginePhase phase = EnginePhase.sendSemanticsTree ])

Repeatedly calls pump with the given duration until there are no longer any transient callbacks scheduled. If no transient callbacks are scheduled when the function is called, it returns without calling pump.

This essentially waits for all animations to have completed.

This function will never return (and the test will hang and eventually time out and fail) if there is an infinite animation in progress (for example, if there is an indeterminate progress indicator spinning).

If the function returns, it returns the number of pumps that it performed.

In general, it is better practice to figure out exactly why each frame is needed, and then to pump exactly as many frames as necessary. This will help catch regressions where, for instance, an animation is being started one frame later than it should.

Alternatively, one can check that the return value from this function matches the expected number of pumps.

Source

Future<int> pumpUntilNoTransientCallbacks([
  @required Duration duration,
  EnginePhase phase = EnginePhase.sendSemanticsTree
]) {
  assert(duration != null);
  assert(duration > Duration.ZERO);
  int count = 0;
  return TestAsyncUtils.guard(() async {
    while (binding.transientCallbackCount > 0) {
      await binding.pump(duration, phase);
      count += 1;
    }
  }).then/*<int>*/((Null _) => count);
}