whenNothingAnimates function

Future<void> whenNothingAnimates({
  1. int besides = 0,
})

Gives up after _stillnessLimit, as a ticker may never stop; besides counts the tickers the caller runs itself, such as its spinner's.

Implementation

Future<void> whenNothingAnimates({int besides = 0}) async {
  final scheduler = SchedulerBinding.instance;
  final waited = Stopwatch()..start();
  while (scheduler.transientCallbackCount > besides &&
      waited.elapsed < _stillnessLimit) {
    await scheduler.endOfFrame;
  }
}