scheduleFrameCallback method Null safety

int scheduleFrameCallback(
  1. FrameCallback callback,
  2. {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 re-registered each time it fires, then when you re-register 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 re-registered. 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.


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