idle method

Future<void> idle ()

Acts as if the application went idle.

Runs all remaining microtasks, including those scheduled as a result of running them, until there are no more microtasks scheduled. Then, runs any previously scheduled timers with zero time, and completes the returned future.

May result in an infinite loop or run out of memory if microtasks continue to recursively schedule new microtasks. Will not run any timers scheduled after this method was invoked, even if they are zero-time timers.

Implementation

Future<void> idle() {
  return TestAsyncUtils.guard<void>(() {
    final Completer<void> completer = Completer<void>();
    Timer.run(() {
      completer.complete();
    });
    return completer.future;
  });
}