settleAnimations method
Waits for running animations, like a page transition or a tap's
ripple, to finish, for at most timeout so a looping animation can't
hold the run.
Implementation
Future<void> settleAnimations({
Duration timeout = const Duration(seconds: 1),
}) async {
final Duration start = _clock.elapsed;
await _clock.frame();
while (SchedulerBinding.instance.transientCallbackCount > 0 &&
_clock.elapsed - start < timeout) {
await _sleep(_frameTime);
}
await _clock.frame();
}