leap method

  1. @visibleForTesting
void leap({
  1. num? highResTimer,
  2. dynamic steps = 1,
})

Advances the animation frame future, without waiting for the window's callback. If there were already an animation frame scheduled, it will cancel it.

ONLY FOR TESTING! DO NOT CALL THIS METHOD IN PRODUCTION CODE!

Implementation

@visibleForTesting
void leap({num? highResTimer, steps = 1}) {
  // Force a angular turn to make sure layout calls are scheduled.
  _ngZone.run(() {});
  while (steps > 0) {
    if (_nextFrameFuture == null) return;
    if (highResTimer == null) {
      highResTimer = DateTime.now().millisecondsSinceEpoch;
    }
    assert(_nextFrameCompleter != null);
    final completer = _nextFrameCompleter!;
    _window.cancelAnimationFrame(_nextFrameId);
    _nextFrameFuture = null;
    _nextFrameCompleter = null;
    completer.complete(highResTimer);
    steps--;
  }
}