From 4f6c2ccc845b8780506a78ad8f87bf46f86b19a2 Mon Sep 17 00:00:00 2001 From: Todd Volkert Date: Mon, 16 Oct 2023 21:52:15 -0400 Subject: [PATCH] Add docs to SchedulerBinding (#136433) Add documentation that I went looking for and didn't find :-) --- .../flutter/lib/src/scheduler/binding.dart | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/flutter/lib/src/scheduler/binding.dart b/packages/flutter/lib/src/scheduler/binding.dart index 2035b84927a..b2cc42bc01c 100644 --- a/packages/flutter/lib/src/scheduler/binding.dart +++ b/packages/flutter/lib/src/scheduler/binding.dart @@ -559,6 +559,11 @@ mixin SchedulerBinding on BindingBase { /// Adds the given callback to the list of frame callbacks and ensures that a /// frame is scheduled. /// + /// If this is called during the frame's animation phase (when transient frame + /// callbacks are still being invoked), a new frame will be scheduled, and + /// `callback` will be called in the newly scheduled frame, not in the current + /// frame. + /// /// 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 @@ -573,6 +578,12 @@ mixin SchedulerBinding on BindingBase { /// /// Callbacks registered with this method can be canceled using /// [cancelFrameCallbackWithId]. + /// + /// See also: + /// + /// * [WidgetsBinding.drawFrame], which explains the phases of each frame + /// for those apps that use Flutter widgets (and where transient frame + /// callbacks fit into those phases). int scheduleFrameCallback(FrameCallback callback, { bool rescheduling = false }) { scheduleFrame(); _nextFrameCallbackId += 1; @@ -725,6 +736,12 @@ mixin SchedulerBinding on BindingBase { /// /// Persistent frame callbacks cannot be unregistered. Once registered, they /// are called for every frame for the lifetime of the application. + /// + /// See also: + /// + /// * [WidgetsBinding.drawFrame], which explains the phases of each frame + /// for those apps that use Flutter widgets (and where persistent frame + /// callbacks fit into those phases). void addPersistentFrameCallback(FrameCallback callback) { _persistentCallbacks.add(callback); } @@ -752,6 +769,9 @@ mixin SchedulerBinding on BindingBase { /// /// * [scheduleFrameCallback], which registers a callback for the start of /// the next frame. + /// * [WidgetsBinding.drawFrame], which explains the phases of each frame + /// for those apps that use Flutter widgets (and where post frame + /// callbacks fit into those phases). void addPostFrameCallback(FrameCallback callback) { _postFrameCallbacks.add(callback); }