Documentation
¶
Overview ¶
Package scheduler schedules frames and callbacks: the SchedulerBinding, Ticker and the frame phases.
Flutter: package:flutter/scheduler.dart.
Index ¶
- Constants
- func DefaultSchedulingStrategy(priority int, scheduler *SchedulerBinding) bool
- func ScheduleTask[T any](b *SchedulerBinding, task func() T, priority Priority, ...) <-chan T
- type FrameCallback
- type Priority
- type ScheduleFrameCallbackOpts
- type ScheduleTaskOpts
- type SchedulerBinding
- func (b *SchedulerBinding) AddPersistentFrameCallback(callback FrameCallback)
- func (b *SchedulerBinding) AddPostFrameCallback(callback FrameCallback)
- func (b *SchedulerBinding) AddTimingsCallback(callback TimingsCallback) TimingsHandle
- func (b *SchedulerBinding) AddUnlockedCallback(fn func())
- func (b *SchedulerBinding) CancelFrameCallbackWithID(id int)
- func (b *SchedulerBinding) CurrentFrameTimeStamp() time.Duration
- func (b *SchedulerBinding) CurrentSystemFrameTimeStamp() time.Duration
- func (b *SchedulerBinding) DebugAssertNoTimeDilation(reason string) bool
- func (b *SchedulerBinding) DebugAssertNoTransientCallbacks(reason string) bool
- func (b *SchedulerBinding) EndOfFrame() <-chan struct{}
- func (b *SchedulerBinding) EnsureFrameCallbacksRegistered()
- func (b *SchedulerBinding) EnsureVisualUpdate()
- func (b *SchedulerBinding) FramesEnabled() bool
- func (b *SchedulerBinding) HandleAppLifecycleStateChanged(state ui.AppLifecycleState)
- func (b *SchedulerBinding) HandleBeginFrame(rawTimeStamp foundation.Opt[time.Duration])
- func (b *SchedulerBinding) HandleDrawFrame()
- func (b *SchedulerBinding) HandleEventLoopCallback() bool
- func (b *SchedulerBinding) HasScheduledFrame() bool
- func (b *SchedulerBinding) LifecycleState() ui.AppLifecycleState
- func (b *SchedulerBinding) LockEvents() (unlock func())
- func (b *SchedulerBinding) Locked() bool
- func (b *SchedulerBinding) PlatformDispatcher() *ui.PlatformDispatcher
- func (b *SchedulerBinding) RemoveTimingsCallback(handle TimingsHandle)
- func (b *SchedulerBinding) ResetEpoch()
- func (b *SchedulerBinding) ResetInternalState()
- func (b *SchedulerBinding) ScheduleForcedFrame()
- func (b *SchedulerBinding) ScheduleFrame()
- func (b *SchedulerBinding) ScheduleFrameCallback(callback FrameCallback, opts ...ScheduleFrameCallbackOpts) int
- func (b *SchedulerBinding) SchedulerPhase() SchedulerPhase
- func (b *SchedulerBinding) SetTimeDilation(value float64)
- func (b *SchedulerBinding) TimeDilation() float64
- func (b *SchedulerBinding) TransientCallbackCount() int
- type SchedulerPhase
- type SchedulingStrategy
- type Ticker
- func (t *Ticker) AbsorbTicker(original *Ticker)
- func (t *Ticker) Dispose()
- func (t *Ticker) IsActive() bool
- func (t *Ticker) IsTicking() bool
- func (t *Ticker) Muted() bool
- func (t *Ticker) SetMuted(value bool)
- func (t *Ticker) Start() *TickerFuture
- func (t *Ticker) Stop(opts ...TickerStopOpts)
- func (t *Ticker) String() string
- type TickerCallback
- type TickerFuture
- type TickerOpts
- type TickerProvider
- type TickerStopOpts
- type TimingsCallback
- type TimingsHandle
Constants ¶
const PriorityMaxOffset = 10000
PriorityMaxOffset is the largest offset Add and Sub use; a larger one is cut to it, so that a priority does not reach the next level.
Flutter: scheduler/priority.dart Priority.kMaxOffset
Variables ¶
This section is empty.
Functions ¶
func DefaultSchedulingStrategy ¶
func DefaultSchedulingStrategy(priority int, scheduler *SchedulerBinding) bool
DefaultSchedulingStrategy runs a task only when it has at least the priority of animation while an animation callback is pending, and any task otherwise.
Flutter: scheduler/binding.dart defaultSchedulingStrategy
func ScheduleTask ¶
func ScheduleTask[T any](b *SchedulerBinding, task func() T, priority Priority, opts ...ScheduleTaskOpts) <-chan T
ScheduleTask schedules the task to run between frames, when the scheduling strategy allows its priority. Tasks of a higher priority run first; those of the same priority run in the order they were scheduled. The returned channel receives the task's result when it ran (and is never written if the task panics).
Flutter: scheduler/binding.dart SchedulerBinding.scheduleTask
Types ¶
type FrameCallback ¶
FrameCallback is a function that is called once per frame, with the time of the frame since an arbitrary point (it counts the time dilation).
Flutter: scheduler/binding.dart FrameCallback
type Priority ¶
type Priority int
Priority is the priority of a task that SchedulerBinding runs between frames. A larger value is more important. The zero value is PriorityIdle.
Flutter: scheduler/priority.dart Priority
const ( // PriorityIdle is the priority of tasks that can wait: nothing is waiting // for them. // // Flutter: scheduler/priority.dart Priority.idle PriorityIdle Priority = 0 // PriorityAnimation is the priority of work that must finish before the // next frame, so that animations do not stutter. // // Flutter: scheduler/priority.dart Priority.animation PriorityAnimation Priority = 100000 // PriorityTouch is the priority of work that responds to user input. // // Flutter: scheduler/priority.dart Priority.touch PriorityTouch Priority = 200000 )
The priorities Flutter defines. Use Add and Sub to get one in between.
func (Priority) Add ¶
Add returns the priority offset more important (or less, for a negative offset). The offset is cut to PriorityMaxOffset.
Flutter: scheduler/priority.dart Priority.+
type ScheduleFrameCallbackOpts ¶
type ScheduleFrameCallbackOpts struct {
// Rescheduling must be set to true only by a callback that registers
// itself again from inside itself. Flutter uses it to keep the stack of the
// first registration; Go keeps no stacks, so it has no effect.
Rescheduling bool
// NoNewFrame stops the call from scheduling a frame; Flutter's
// scheduleNewFrame is true by default.
NoNewFrame bool
}
ScheduleFrameCallbackOpts are the optional parameters of ScheduleFrameCallback.
Flutter: scheduler/binding.dart SchedulerBinding.scheduleFrameCallback
type ScheduleTaskOpts ¶
type ScheduleTaskOpts struct {
// DebugLabel names the task in debug output.
DebugLabel string
}
ScheduleTaskOpts are the optional parameters of ScheduleTask.
Flutter: scheduler/binding.dart SchedulerBinding.scheduleTask
type SchedulerBinding ¶
type SchedulerBinding struct {
// SchedulingStrategy decides which tasks run now. The default is
// DefaultSchedulingStrategy.
//
// Flutter: scheduler/binding.dart SchedulerBinding.schedulingStrategy
SchedulingStrategy SchedulingStrategy
// ErrorReporter receives the panics of tasks and frame callbacks, which are
// recovered so that the others still run. Without one, a panic goes on and
// ends the frame. The binding that owns the scheduler sets it (SPEC §14.2).
//
// Flutter: foundation/assertions.dart FlutterError.onError
ErrorReporter foundation.ErrorReporter
// FramesGate, when set, is a further condition for FramesEnabled: the
// widgets binding keeps frames off until the root widget is attached.
//
// Flutter: widgets/binding.dart WidgetsBinding.framesEnabled
FramesGate func() bool
// contains filtered or unexported fields
}
SchedulerBinding schedules the work of the framework around the frames of the platform: tasks between frames, the callbacks of a frame in three groups, and the flow of a frame through its phases.
It listens to the dispatcher's OnBeginFrame and OnDrawFrame (when nothing else does yet), and asks it for frames. The bindings of the framework embed it. There is one per app and it belongs to the UI thread.
Flutter: scheduler/binding.dart SchedulerBinding
func NewSchedulerBinding ¶
func NewSchedulerBinding(d *ui.PlatformDispatcher) *SchedulerBinding
NewSchedulerBinding creates the binding for a dispatcher. It reads the lifecycle state the dispatcher already has: a state that is hidden, paused or detached stops frames from the start.
Flutter: scheduler/binding.dart SchedulerBinding.initInstances
func (*SchedulerBinding) AddPersistentFrameCallback ¶
func (b *SchedulerBinding) AddPersistentFrameCallback(callback FrameCallback)
AddPersistentFrameCallback adds a callback that runs at the end of every frame, for the life of the app: it builds, lays out and paints. It cannot be removed. A callback added during a frame first runs in the next one.
Flutter: scheduler/binding.dart SchedulerBinding.addPersistentFrameCallback
func (*SchedulerBinding) AddPostFrameCallback ¶
func (b *SchedulerBinding) AddPostFrameCallback(callback FrameCallback)
AddPostFrameCallback adds a callback that runs once after the next frame (it does not schedule one). A callback added by a post-frame callback runs after the frame after.
Flutter: scheduler/binding.dart SchedulerBinding.addPostFrameCallback
func (*SchedulerBinding) AddTimingsCallback ¶
func (b *SchedulerBinding) AddTimingsCallback(callback TimingsCallback) TimingsHandle
AddTimingsCallback adds a callback for the timings of the frames. The engine measures them only while a callback is set, so adding one has a cost: remove it when the timings are not used any more. A callback that panics is reported to the ErrorReporter (CallbackPanicked, "while reporting frame timings") and the others still run.
Deviation: Flutter removes a callback by the function; functions are not comparable in Go, so the add gives a handle (SPEC §12.10).
Flutter: scheduler/binding.dart SchedulerBinding.addTimingsCallback
func (*SchedulerBinding) AddUnlockedCallback ¶
func (b *SchedulerBinding) AddUnlockedCallback(fn func())
AddUnlockedCallback adds a function that runs each time the last lock is released. Bindings that hold events while locked use it to deliver them.
Flutter: foundation/binding.dart BindingBase.unlocked
func (*SchedulerBinding) CancelFrameCallbackWithID ¶
func (b *SchedulerBinding) CancelFrameCallbackWithID(id int)
CancelFrameCallbackWithID cancels a callback scheduled with ScheduleFrameCallback, also while the frame that would run it is already running its callbacks. The ID must be larger than zero.
Flutter: scheduler/binding.dart SchedulerBinding.cancelFrameCallbackWithId
func (*SchedulerBinding) CurrentFrameTimeStamp ¶
func (b *SchedulerBinding) CurrentFrameTimeStamp() time.Duration
CurrentFrameTimeStamp is the time of the frame being built, since the epoch and with the time dilation. It panics with the tag NoFrameInProgress outside a frame.
Flutter: scheduler/binding.dart SchedulerBinding.currentFrameTimeStamp
func (*SchedulerBinding) CurrentSystemFrameTimeStamp ¶
func (b *SchedulerBinding) CurrentSystemFrameTimeStamp() time.Duration
CurrentSystemFrameTimeStamp is the raw time of the last frame, as the platform gave it, without epoch or time dilation.
Flutter: scheduler/binding.dart SchedulerBinding.currentSystemFrameTimeStamp
func (*SchedulerBinding) DebugAssertNoTimeDilation ¶
func (b *SchedulerBinding) DebugAssertNoTimeDilation(reason string) bool
DebugAssertNoTimeDilation panics with the tag TimeDilationActive in debug builds when the time dilation is not 1. It returns true.
Flutter: scheduler/binding.dart SchedulerBinding.debugAssertNoTimeDilation
func (*SchedulerBinding) DebugAssertNoTransientCallbacks ¶
func (b *SchedulerBinding) DebugAssertNoTransientCallbacks(reason string) bool
DebugAssertNoTransientCallbacks panics with the tag TransientCallbacksPending in debug builds when transient callbacks are still waiting. It returns true.
Flutter lists the stack of each callback that is still waiting; Go keeps no such stacks, so the count is all there is.
Flutter: scheduler/binding.dart SchedulerBinding.debugAssertNoTransientCallbacks
func (*SchedulerBinding) EndOfFrame ¶
func (b *SchedulerBinding) EndOfFrame() <-chan struct{}
EndOfFrame returns a channel that is closed after the next frame has been drawn (in the post-frame phase). It schedules a frame if none is being built.
Flutter: scheduler/binding.dart SchedulerBinding.endOfFrame
func (*SchedulerBinding) EnsureFrameCallbacksRegistered ¶
func (b *SchedulerBinding) EnsureFrameCallbacksRegistered()
EnsureFrameCallbacksRegistered makes the binding the listener of the dispatcher's OnBeginFrame and OnDrawFrame, unless something else already is. ScheduleFrame calls it.
Flutter: scheduler/binding.dart SchedulerBinding.ensureFrameCallbacksRegistered
func (*SchedulerBinding) EnsureVisualUpdate ¶
func (b *SchedulerBinding) EnsureVisualUpdate()
EnsureVisualUpdate schedules a frame if the binding is idle or in the post-frame phase, and does nothing during the frame itself, which is about to draw anyway. Call it when something changes that should show.
Flutter: scheduler/binding.dart SchedulerBinding.ensureVisualUpdate
func (*SchedulerBinding) FramesEnabled ¶
func (b *SchedulerBinding) FramesEnabled() bool
FramesEnabled reports whether frames are produced. They are not while the app is hidden, paused or detached.
Flutter: scheduler/binding.dart SchedulerBinding.framesEnabled
func (*SchedulerBinding) HandleAppLifecycleStateChanged ¶
func (b *SchedulerBinding) HandleAppLifecycleStateChanged(state ui.AppLifecycleState)
HandleAppLifecycleStateChanged tells the binding the app lifecycle changed. Frames stop while the app is hidden, paused or detached, and start again (a frame is scheduled) when it is resumed or inactive. The app's binding calls this; an app does not.
Flutter: scheduler/binding.dart SchedulerBinding.handleAppLifecycleStateChanged
func (*SchedulerBinding) HandleBeginFrame ¶
func (b *SchedulerBinding) HandleBeginFrame(rawTimeStamp foundation.Opt[time.Duration])
HandleBeginFrame starts a frame: the transient callbacks run, with the frame time. The dispatcher's OnBeginFrame calls it; tests call it too. None as the raw time stands for a frame without a platform time (the time of the last one is used).
The binding must be idle. Callbacks scheduled by the callbacks run in the next frame; one canceled by an earlier callback of the same frame does not run.
A callback that panics is reported to the ErrorReporter (CallbackPanicked, "during a scheduler callback") and the others still run.
Flutter: scheduler/binding.dart SchedulerBinding.handleBeginFrame
func (*SchedulerBinding) HandleDrawFrame ¶
func (b *SchedulerBinding) HandleDrawFrame()
HandleDrawFrame ends a frame: the persistent callbacks run, then the post-frame callbacks, and the binding is idle again. The dispatcher's OnDrawFrame calls it, after HandleBeginFrame.
A callback that panics is reported to the ErrorReporter (CallbackPanicked, "during a scheduler callback") and the others still run.
Flutter: scheduler/binding.dart SchedulerBinding.handleDrawFrame
func (*SchedulerBinding) HandleEventLoopCallback ¶
func (b *SchedulerBinding) HandleEventLoopCallback() bool
HandleEventLoopCallback runs the most important task if the scheduling strategy allows it. It reports whether there is more to do: tasks waiting, or one that the strategy did not allow yet. The event loop calls it; tests call it too.
A task that panics is reported to the ErrorReporter (CallbackPanicked, "during a task callback") and the event loop goes on.
Flutter: scheduler/binding.dart SchedulerBinding.handleEventLoopCallback
func (*SchedulerBinding) HasScheduledFrame ¶
func (b *SchedulerBinding) HasScheduledFrame() bool
HasScheduledFrame reports whether a frame was requested and has not begun.
Flutter: scheduler/binding.dart SchedulerBinding.hasScheduledFrame
func (*SchedulerBinding) LifecycleState ¶
func (b *SchedulerBinding) LifecycleState() ui.AppLifecycleState
LifecycleState is the last lifecycle state the binding was told about, or AppLifecycleStateUnspecified.
Flutter: scheduler/binding.dart SchedulerBinding.lifecycleState
func (*SchedulerBinding) LockEvents ¶
func (b *SchedulerBinding) LockEvents() (unlock func())
LockEvents stops tasks (and, for the bindings that use Locked, input) from running until the returned function is called. Calls nest. When the last lock is released, the callbacks added with AddUnlockedCallback run and the waiting tasks start again. Call the returned function once.
Deviation: Flutter's lockEvents takes a callback that returns a Future and unlocks when it completes (SPEC §12.10).
Flutter: foundation/binding.dart BindingBase.lockEvents
func (*SchedulerBinding) Locked ¶
func (b *SchedulerBinding) Locked() bool
Locked reports whether input and tasks are held back (see LockEvents).
Flutter: foundation/binding.dart BindingBase.locked
func (*SchedulerBinding) PlatformDispatcher ¶
func (b *SchedulerBinding) PlatformDispatcher() *ui.PlatformDispatcher
PlatformDispatcher is the dispatcher the binding schedules frames with.
Flutter: foundation/binding.dart BindingBase.platformDispatcher
func (*SchedulerBinding) RemoveTimingsCallback ¶
func (b *SchedulerBinding) RemoveTimingsCallback(handle TimingsHandle)
RemoveTimingsCallback removes the callback; a handle that was removed already does nothing. When the last one is removed the engine stops measuring.
Flutter: scheduler/binding.dart SchedulerBinding.removeTimingsCallback
func (*SchedulerBinding) ResetEpoch ¶
func (b *SchedulerBinding) ResetEpoch()
ResetEpoch makes the next frame time start from the last one, so that a gap (a change of the time dilation, a pause) does not show as a jump.
Flutter: scheduler/binding.dart SchedulerBinding.resetEpoch
func (*SchedulerBinding) ResetInternalState ¶
func (b *SchedulerBinding) ResetInternalState()
ResetInternalState puts the binding back to its state at the start: no lifecycle state, and frames enabled. Tests use it.
Flutter: scheduler/binding.dart SchedulerBinding.resetInternalState
func (*SchedulerBinding) ScheduleForcedFrame ¶
func (b *SchedulerBinding) ScheduleForcedFrame()
ScheduleForcedFrame is ScheduleFrame that also works while frames are disabled.
Flutter: scheduler/binding.dart SchedulerBinding.scheduleForcedFrame
func (*SchedulerBinding) ScheduleFrame ¶
func (b *SchedulerBinding) ScheduleFrame()
ScheduleFrame asks the platform for a frame, once: asking again before it begins does nothing, and nothing happens while frames are disabled.
Flutter: scheduler/binding.dart SchedulerBinding.scheduleFrame
func (*SchedulerBinding) ScheduleFrameCallback ¶
func (b *SchedulerBinding) ScheduleFrameCallback(callback FrameCallback, opts ...ScheduleFrameCallbackOpts) int
ScheduleFrameCallback schedules the callback to run once at the start of the next frame (a transient callback: animations). It schedules a frame unless NoNewFrame is set. The returned ID cancels it with CancelFrameCallbackWithID.
Callbacks scheduled during a frame's callbacks run in the next frame.
Flutter: scheduler/binding.dart SchedulerBinding.scheduleFrameCallback
func (*SchedulerBinding) SchedulerPhase ¶
func (b *SchedulerBinding) SchedulerPhase() SchedulerPhase
SchedulerPhase is where the binding is in the life of a frame.
Flutter: scheduler/binding.dart SchedulerBinding.schedulerPhase
func (*SchedulerBinding) SetTimeDilation ¶
func (b *SchedulerBinding) SetTimeDilation(value float64)
SetTimeDilation sets the time dilation, which must be larger than zero (or it panics with the tag TimeDilationInvalid in debug builds). The epoch restarts first, so that the frame times stay continuous.
Flutter: scheduler/binding.dart timeDilation=
func (*SchedulerBinding) TimeDilation ¶
func (b *SchedulerBinding) TimeDilation() float64
TimeDilation is how much slower the frame times run than the real time; 1 by default. A value of 2 slows animations to half their speed.
Flutter: scheduler/binding.dart timeDilation
func (*SchedulerBinding) TransientCallbackCount ¶
func (b *SchedulerBinding) TransientCallbackCount() int
TransientCallbackCount is how many transient frame callbacks wait for the next frame.
Flutter: scheduler/binding.dart SchedulerBinding.transientCallbackCount
type SchedulerPhase ¶
type SchedulerPhase int
SchedulerPhase is where the binding is in the life of a frame.
Flutter: scheduler/binding.dart SchedulerPhase
const ( // SchedulerPhaseUnspecified is the zero value; a binding is never in it. // // Flutter: no counterpart SchedulerPhaseUnspecified SchedulerPhase = iota // SchedulerPhaseIdle means no frame is being built. Tasks and microtasks // run, and so do input and timers. // // Flutter: scheduler/binding.dart SchedulerPhase.idle SchedulerPhaseIdle // SchedulerPhaseTransientCallbacks is the start of a frame: the callbacks // that update animations run (HandleBeginFrame). // // Flutter: scheduler/binding.dart SchedulerPhase.transientCallbacks SchedulerPhaseTransientCallbacks // SchedulerPhaseMidFrameMicrotasks is the time between the transient and // the persistent callbacks. // // Flutter: scheduler/binding.dart SchedulerPhase.midFrameMicrotasks SchedulerPhaseMidFrameMicrotasks // SchedulerPhasePersistentCallbacks is where the frame is built: build, // layout and paint (HandleDrawFrame). // // Flutter: scheduler/binding.dart SchedulerPhase.persistentCallbacks SchedulerPhasePersistentCallbacks // SchedulerPhasePostFrameCallbacks is the end of a frame: the callbacks // that run once after it. // // Flutter: scheduler/binding.dart SchedulerPhase.postFrameCallbacks SchedulerPhasePostFrameCallbacks )
The values of SchedulerPhase follow Flutter's declaration order.
func (SchedulerPhase) Name ¶
func (p SchedulerPhase) Name() string
Name returns the name Dart's Enum.name gives the value, such as "idle".
func (SchedulerPhase) String ¶
func (p SchedulerPhase) String() string
String returns the name Dart prints for the value, such as "SchedulerPhase.idle".
type SchedulingStrategy ¶
type SchedulingStrategy func(priority int, scheduler *SchedulerBinding) bool
SchedulingStrategy decides whether a task of the given priority runs now. The default is DefaultSchedulingStrategy.
Flutter: scheduler/binding.dart SchedulingStrategy
type Ticker ¶
type Ticker struct {
// ForceFrames makes the ticker schedule frames with ScheduleForcedFrame,
// which works while frames are disabled.
//
// Flutter: scheduler/ticker.dart Ticker.forceFrames
ForceFrames bool
// DebugLabel names the ticker in debug output.
//
// Flutter: scheduler/ticker.dart Ticker.debugLabel
DebugLabel string
// OnDispose, if set, is called when the ticker is disposed, before it stops.
// A TickerProvider uses it to forget the tickers it made.
//
// Deviation: Flutter's _WidgetTicker overrides dispose in a subclass.
OnDispose func()
// contains filtered or unexported fields
}
Ticker calls its callback once per frame, from the frame after it is started until it is stopped. The time it passes is relative to the first frame it ticked in, so that animations start at zero.
A ticker stops ticking (but stays active) while it is muted, and while frames are disabled (the app is hidden or paused).
Flutter: scheduler/ticker.dart Ticker
func NewTicker ¶
func NewTicker(binding *SchedulerBinding, onTick TickerCallback, opts ...TickerOpts) *Ticker
NewTicker creates a ticker that calls onTick, on the binding's frames. It is not started; call Start. Dispose it when it is no longer needed.
Flutter: scheduler/ticker.dart Ticker.new
func (*Ticker) AbsorbTicker ¶
AbsorbTicker makes this ticker take over the state of another: if the other was started, this one is active with the same TickerFuture and start time, and keeps ticking from where it was. The other is disposed. This ticker must not be active. A State uses it when its TickerProvider changes.
Flutter: scheduler/ticker.dart Ticker.absorbTicker
func (*Ticker) Dispose ¶
func (t *Ticker) Dispose()
Dispose stops the ticker and cancels its TickerFuture, if it is active. A disposed ticker cannot be started.
Flutter: scheduler/ticker.dart Ticker.dispose
func (*Ticker) IsActive ¶
IsActive reports whether the ticker was started and not stopped. A muted ticker is active.
Flutter: scheduler/ticker.dart Ticker.isActive
func (*Ticker) IsTicking ¶
IsTicking reports whether the ticker will call its callback on frames: it is active, not muted, and frames are enabled (or a frame is being built).
Flutter: scheduler/ticker.dart Ticker.isTicking
func (*Ticker) Muted ¶
Muted reports whether the ticker is muted: it stays active but does not tick.
Flutter: scheduler/ticker.dart Ticker.muted
func (*Ticker) SetMuted ¶
SetMuted mutes or unmutes the ticker. A muted ticker does not tick and schedules no frames; an unmuted one that is active starts again, with its start time unchanged, so that time passes for it while it was muted.
Flutter: scheduler/ticker.dart Ticker.muted=
func (*Ticker) Start ¶
func (t *Ticker) Start() *TickerFuture
Start starts the ticker, and returns the TickerFuture that completes when it is stopped. Starting a ticker that is active panics with the tag TickerStartedTwice in debug builds, and so does starting a disposed one with TickerUsedAfterDispose.
Flutter: scheduler/ticker.dart Ticker.start
func (*Ticker) Stop ¶
func (t *Ticker) Stop(opts ...TickerStopOpts)
Stop stops the ticker, if it is active. The TickerFuture it returned from Start completes, or ends as canceled with Canceled.
Flutter: scheduler/ticker.dart Ticker.stop
type TickerCallback ¶
TickerCallback is called by a Ticker once per frame, with the time since the ticker started (with the time dilation).
Flutter: scheduler/ticker.dart TickerCallback
type TickerFuture ¶
type TickerFuture struct {
// contains filtered or unexported fields
}
TickerFuture is what a Ticker's Start returns: it completes when the ticker is stopped. Flutter's is a Future; Glutter's has a channel and callbacks (SPEC §12.6).
A canceled ticker never completes its Done channel; its OrCancel channel gets a TickerCanceled error instead.
Callbacks run at once, on the goroutine that stops the ticker (the UI thread), not in a later microtask as Dart's futures do.
Flutter: scheduler/ticker.dart TickerFuture
func NewTickerFutureComplete ¶
func NewTickerFutureComplete() *TickerFuture
NewTickerFutureComplete creates a future that is complete already, for an animation that does not run.
Flutter: scheduler/ticker.dart TickerFuture.complete
func NewTickerFuturePending ¶
func NewTickerFuturePending() (future *TickerFuture, complete func())
NewTickerFuturePending creates a future that is not complete, and the function that completes it. Code that has no ticker (a scroll activity that completes when it is disposed) uses it where Dart uses a Completer<void>. Calling the function again does nothing.
Flutter: no counterpart (dart:async Completer<void>)
func WaitTickerFutures ¶
func WaitTickerFutures(futures ...*TickerFuture) *TickerFuture
WaitTickerFutures returns a future that completes when all the futures have completed (immediately if there are none). A future that is canceled never completes it.
Flutter: no counterpart (dart:async Future.wait)
func (*TickerFuture) Completed ¶
func (f *TickerFuture) Completed() (completed, ended bool)
Completed reports whether the ticker completed (true) or was canceled (false); the second result is false while it runs.
func (*TickerFuture) Done ¶
func (f *TickerFuture) Done() <-chan struct{}
Done returns a channel that is closed when the ticker completes (is stopped without being canceled). It is never closed if the ticker is canceled; use OrCancel to learn of both.
Flutter: scheduler/ticker.dart TickerFuture.then
func (*TickerFuture) OrCancel ¶
func (f *TickerFuture) OrCancel() <-chan error
OrCancel returns a channel that gets nil when the ticker completes and a TickerCanceled error when it is canceled; the value is there at once if that already happened. Each call returns a new channel.
Flutter: scheduler/ticker.dart TickerFuture.orCancel
func (*TickerFuture) String ¶
func (f *TickerFuture) String() string
String describes the future, such as "TickerFuture#1a2b3(active)".
Flutter: scheduler/ticker.dart TickerFuture.toString
func (*TickerFuture) Then ¶
func (f *TickerFuture) Then(fn func())
Then calls fn when the ticker completes, at once if it already did. It is never called if the ticker is canceled.
Flutter: scheduler/ticker.dart TickerFuture.then
func (*TickerFuture) WhenCompleteOrCancel ¶
func (f *TickerFuture) WhenCompleteOrCancel(fn func())
WhenCompleteOrCancel calls fn when the ticker completes or is canceled, at once if it already ended.
Flutter: scheduler/ticker.dart TickerFuture.whenCompleteOrCancel
type TickerOpts ¶
type TickerOpts struct {
// DebugLabel names the ticker in debug output.
DebugLabel string
}
TickerOpts are the optional parameters of NewTicker.
Flutter: scheduler/ticker.dart Ticker.new
type TickerProvider ¶
type TickerProvider interface {
// CreateTicker makes a ticker that calls onTick. The caller must Dispose
// it.
//
// Flutter: scheduler/ticker.dart TickerProvider.createTicker
CreateTicker(onTick TickerCallback) *Ticker
}
TickerProvider is an object that makes Tickers. A State that needs one embeds SingleTickerProvider or TickerProviderMixin (steps 8.2 and 7.1).
Flutter: scheduler/ticker.dart TickerProvider
type TickerStopOpts ¶
type TickerStopOpts struct {
// Canceled makes the TickerFuture end as canceled (its OrCancel channel
// gets a TickerCanceled error) instead of completing.
Canceled bool
}
TickerStopOpts are the optional parameters of Ticker.Stop.
Flutter: scheduler/ticker.dart Ticker.stop
type TimingsCallback ¶
type TimingsCallback func(timings []ui.FrameTiming)
TimingsCallback is called with the timings of the frames that the engine drew since the last call.
Flutter: dart:ui TimingsCallback
type TimingsHandle ¶
type TimingsHandle struct {
// contains filtered or unexported fields
}
TimingsHandle identifies a callback added with AddTimingsCallback, to remove it.
Flutter: no counterpart