scheduleFrameCallback method

int scheduleFrameCallback (FrameCallback callback, { bool rescheduling: false })

Schedules the given transient frame callback.

Adds the given callback to the list of frame callbacks and ensures that a frame is scheduled.

If this is a one-off registration, ignore the rescheduling argument.

If this is a callback that will be reregistered each time it fires, then when you reregister the callback, set the rescheduling argument to true. This has no effect in release builds, but in debug builds, it ensures that the stack trace that is stored for this callback is the original stack trace for when the callback was first registered, rather than the stack trace for when the callback is reregistered. This makes it easier to track down the original reason that a particular callback was called. If rescheduling is true, the call must be in the context of a frame callback.

Callbacks registered with this method can be canceled using cancelFrameCallbackWithId.

Implementation

int scheduleFrameCallback(FrameCallback callback, { bool rescheduling = false }) {
  scheduleFrame();
  _nextFrameCallbackId += 1;
  _transientCallbacks[_nextFrameCallbackId] = _FrameCallbackEntry(callback, rescheduling: rescheduling);
  return _nextFrameCallbackId;
}