onBeginFrame property

FrameCallback? onBeginFrame

A callback that is invoked to notify the window that it is an appropriate time to provide a scene using the SceneBuilder API and the render method.

Accessing this value returns the value contained in the PlatformDispatcher singleton, so instead of getting it from here, you should consider getting it from WidgetsBinding.instance.platformDispatcher instead (or, when WidgetsBinding isn't available, from PlatformDispatcher.instance). The reason this value forwards to the PlatformDispatcher is to provide convenience for applications that only use a single main window.

When possible, this is driven by the hardware VSync signal. This is only called if scheduleFrame has been called since the last time this callback was invoked.

The onDrawFrame callback is invoked immediately after onBeginFrame, after draining any microtasks (e.g. completions of any Futures) queued by the onBeginFrame handler.

The framework invokes this callback in the same zone in which the callback was set.

See also:

  • SchedulerBinding, the Flutter framework class which manages the scheduling of frames.
  • RendererBinding, the Flutter framework class which manages layout and painting.

Implementation

FrameCallback? get onBeginFrame => platformDispatcher.onBeginFrame;
void onBeginFrame=(FrameCallback? callback)

Implementation

set onBeginFrame(FrameCallback? callback) {
  platformDispatcher.onBeginFrame = callback;
}