pumpEventQueue function
- int times = 20,
Returns a Future that completes after the event loop has run the given
number of times
(20 by default).
Awaiting this approximates waiting until all asynchronous work (other than work that's waiting for external resources) completes.
Implementation
Future pumpEventQueue({int times = 20}) {
if (times == 0) return Future.value();
// Use the event loop to allow the microtask queue to finish.
return Future(() => pumpEventQueue(times: times - 1));
}