onDrawFrame property

VoidCallback? onDrawFrame

A callback that is invoked for each frame after onBeginFrame has completed and after the microtask queue has been drained.

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.

This can be used to implement a second phase of frame rendering that happens after any deferred work queued by the onBeginFrame phase.

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

VoidCallback? get onDrawFrame => platformDispatcher.onDrawFrame;
void onDrawFrame=(VoidCallback? callback)

Implementation

set onDrawFrame(VoidCallback? callback) {
  platformDispatcher.onDrawFrame = callback;
}