parent
808cd092a0
commit
80ab0f64b4
@ -63,7 +63,7 @@ class _FrameCallbackEntry {
|
|||||||
assert(() {
|
assert(() {
|
||||||
if (debugCurrentCallbackStack == null) {
|
if (debugCurrentCallbackStack == null) {
|
||||||
throw new FlutterError(
|
throw new FlutterError(
|
||||||
'addFrameCallback or scheduleFrameCallback called with rescheduling true, but no callback is in scope.\n'
|
'scheduleFrameCallback called with rescheduling true, but no callback is in scope.\n'
|
||||||
'The "rescheduling" argument should only be set to true if the '
|
'The "rescheduling" argument should only be set to true if the '
|
||||||
'callback is being reregistered from within the callback itself, '
|
'callback is being reregistered from within the callback itself, '
|
||||||
'and only then if the callback itself is entirely synchronous. '
|
'and only then if the callback itself is entirely synchronous. '
|
||||||
@ -108,8 +108,7 @@ enum SchedulerPhase {
|
|||||||
idle,
|
idle,
|
||||||
|
|
||||||
/// The transient callbacks (scheduled by
|
/// The transient callbacks (scheduled by
|
||||||
/// [WidgetsBinding.scheduleFrameCallback] and
|
/// [WidgetsBinding.scheduleFrameCallback]) are currently executing.
|
||||||
/// [WidgetsBinding.addFrameCallback]) are currently executing.
|
|
||||||
///
|
///
|
||||||
/// Typically, these callbacks handle updating objects to new animation states.
|
/// Typically, these callbacks handle updating objects to new animation states.
|
||||||
transientCallbacks,
|
transientCallbacks,
|
||||||
@ -262,36 +261,7 @@ abstract class SchedulerBinding extends BindingBase {
|
|||||||
/// [cancelFrameCallbackWithId].
|
/// [cancelFrameCallbackWithId].
|
||||||
int scheduleFrameCallback(FrameCallback callback, { bool rescheduling: false }) {
|
int scheduleFrameCallback(FrameCallback callback, { bool rescheduling: false }) {
|
||||||
scheduleFrame();
|
scheduleFrame();
|
||||||
return addFrameCallback(callback, rescheduling: rescheduling);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 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].
|
|
||||||
int addFrameCallback(FrameCallback callback, { bool rescheduling: false }) {
|
|
||||||
_nextFrameCallbackId += 1;
|
_nextFrameCallbackId += 1;
|
||||||
_transientCallbacks[_nextFrameCallbackId] = new _FrameCallbackEntry(callback, rescheduling: rescheduling);
|
_transientCallbacks[_nextFrameCallbackId] = new _FrameCallbackEntry(callback, rescheduling: rescheduling);
|
||||||
return _nextFrameCallbackId;
|
return _nextFrameCallbackId;
|
||||||
@ -303,7 +273,7 @@ abstract class SchedulerBinding extends BindingBase {
|
|||||||
/// has been requested, this does not also cancel that request.
|
/// has been requested, this does not also cancel that request.
|
||||||
///
|
///
|
||||||
/// Transient frame callbacks are those registered using
|
/// Transient frame callbacks are those registered using
|
||||||
/// [scheduleFrameCallback] or [addFrameCallback].
|
/// [scheduleFrameCallback].
|
||||||
void cancelFrameCallbackWithId(int id) {
|
void cancelFrameCallbackWithId(int id) {
|
||||||
assert(id > 0);
|
assert(id > 0);
|
||||||
_transientCallbacks.remove(id);
|
_transientCallbacks.remove(id);
|
||||||
@ -314,7 +284,7 @@ abstract class SchedulerBinding extends BindingBase {
|
|||||||
/// there are, prints their locations and throws an exception.
|
/// there are, prints their locations and throws an exception.
|
||||||
///
|
///
|
||||||
/// A transient frame callback is one that was registered with
|
/// A transient frame callback is one that was registered with
|
||||||
/// [scheduleFrameCallback] or [addFrameCallback].
|
/// [scheduleFrameCallback].
|
||||||
///
|
///
|
||||||
/// This is expected to be called at the end of tests (the
|
/// This is expected to be called at the end of tests (the
|
||||||
/// flutter_test framework does it automatically in normal cases).
|
/// flutter_test framework does it automatically in normal cases).
|
||||||
@ -369,12 +339,11 @@ abstract class SchedulerBinding extends BindingBase {
|
|||||||
/// Prints the stack for where the current transient callback was registered.
|
/// Prints the stack for where the current transient callback was registered.
|
||||||
///
|
///
|
||||||
/// A transient frame callback is one that was registered with
|
/// A transient frame callback is one that was registered with
|
||||||
/// [scheduleFrameCallback] or [addFrameCallback].
|
/// [scheduleFrameCallback].
|
||||||
///
|
///
|
||||||
/// When called in debug more and in the context of a transient callback, this
|
/// When called in debug more and in the context of a transient callback, this
|
||||||
/// function prints the stack trace from where the current transient callback
|
/// function prints the stack trace from where the current transient callback
|
||||||
/// was registered (i.e. where it first called addFrameCallback or
|
/// was registered (i.e. where it first called [scheduleFrameCallback]).
|
||||||
/// scheduleFrameCallback).
|
|
||||||
///
|
///
|
||||||
/// When called in debug mode in other contexts, it prints a message saying
|
/// When called in debug mode in other contexts, it prints a message saying
|
||||||
/// that this function was not called in the context a transient callback.
|
/// that this function was not called in the context a transient callback.
|
||||||
@ -552,7 +521,7 @@ abstract class SchedulerBinding extends BindingBase {
|
|||||||
/// Called by the engine to produce a new frame.
|
/// Called by the engine to produce a new frame.
|
||||||
///
|
///
|
||||||
/// This function first calls all the callbacks registered by
|
/// This function first calls all the callbacks registered by
|
||||||
/// [scheduleFrameCallback]/[addFrameCallback], then calls all the callbacks
|
/// [scheduleFrameCallback], then calls all the callbacks
|
||||||
/// registered by [addPersistentFrameCallback], which typically drive the
|
/// registered by [addPersistentFrameCallback], which typically drive the
|
||||||
/// rendering pipeline, and finally calls the callbacks registered by
|
/// rendering pipeline, and finally calls the callbacks registered by
|
||||||
/// [addPostFrameCallback].
|
/// [addPostFrameCallback].
|
||||||
|
@ -285,7 +285,7 @@ abstract class WidgetsBinding extends BindingBase implements GestureBinding, Ren
|
|||||||
///
|
///
|
||||||
/// 1. The animation phase: The [handleBeginFrame] method, which is registered
|
/// 1. The animation phase: The [handleBeginFrame] method, which is registered
|
||||||
/// with [ui.window.onBeginFrame], invokes all the transient frame callbacks
|
/// with [ui.window.onBeginFrame], invokes all the transient frame callbacks
|
||||||
/// registered with [scheduleFrameCallback] and [addFrameCallback], in
|
/// registered with [scheduleFrameCallback], in
|
||||||
/// registration order. This includes all the [Ticker] instances that are
|
/// registration order. This includes all the [Ticker] instances that are
|
||||||
/// driving [AnimationController] objects, which means all of the active
|
/// driving [AnimationController] objects, which means all of the active
|
||||||
/// [Animation] objects tick at this point.
|
/// [Animation] objects tick at this point.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user