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

Adds a transient frame callback.

Frame callbacks are executed at the beginning of a frame (see handleBeginFrame).

These callbacks are executed in the order in which they have been added.

Callbacks registered with this method will not be called until a frame is requested. To register a callback and ensure that a frame is immediately scheduled, use scheduleFrameCallback.

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.

Source

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