requestAnimationFrame method

void requestAnimationFrame(
  1. dynamic callback()
)
inherited

Calls Window.requestAnimationFrame with the specified callback, and keeps track of the request ID so that it can be cancelled in cancelAnimationFrames.

Implementation

void requestAnimationFrame(Function() callback) {
  int? queuedId;
  queuedId = window.requestAnimationFrame((_) {
    callback();
    _animationFrameIds.remove(queuedId);
  });

  _animationFrameIds.add(queuedId);
}