bindingAwarePump function

Future<void> bindingAwarePump(
  1. WidgetTester tester, {
  2. Duration interval = const Duration(milliseconds: 100),
})

Pumps the tester in a way that works correctly in both AutomatedTestWidgetsFlutterBinding (fake async) and live/preview bindings (real async).

  • Automated binding: calls tester.pump(interval) to advance the fake clock by interval, firing any timers scheduled within that window.
  • Live/Preview binding: calls tester.pump() without a duration so the frame renders immediately on the next vsync. Real timers fire naturally.

Implementation

Future<void> bindingAwarePump(
  WidgetTester tester, {
  Duration interval = const Duration(milliseconds: 100),
}) async {
  if (isLiveBinding) {
    await tester.pump();
  } else {
    await tester.pump(interval);
  }
}