MotionPlayer class

A motion, with a clock.

Seeking is pure and always legal — assign position or progress, in any direction, from any state, without starting anything. Playing owns a ticker: play runs to the end, reverse runs back to zero, repeat keeps going. pause keeps the picture, finish jumps to the end pose and holds it, and stop is cancel — the fx drops, the authored values were never touched, and scene time is back at zero.

A ChangeNotifier, so AnimatedBuilder(animation: player) redraws a scrubber or a play button. The SCENE needs none of that: applying a frame writes into the document, which notifies whatever is drawing it.

A player that reached its end holds no frame callbacks, so forgetting to dispose one is harmless; dispose matters exactly while it might still be playing.

Mixed-in types

Constructors

MotionPlayer(SceneMotion<SceneDefinition> motion, {required TickerProvider? vsync})
Plays a motion an app COMPILED — MotionPlayer(BannerIntro(scene), vsync: this), which is the whole of starting one.
MotionPlayer.bound(Playable playable, {required TickerProvider? vsync})
Plays a motion already bound to its scene — the BoundMotion the editor makes from a file it read, or any playable tree.

Properties

duration → Duration
no setter
finished → Future<void>
Completes when the current playback ends, HOWEVER it ends — running out of timeline, finish, or stop. Ask status which.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
isPlaying → bool
no setter
playable ↔ Playable
What plays. Replaced by retarget when the scene it animates is rebuilt under it — a theme flipped while an intro plays.
getter/setter pair
position ↔ Duration
Where the playhead is. Assigning parks it there and draws that moment: pure, any state, any direction, and it starts no clock. Past the end is legal and holds the end pose — an editor needs the playhead beyond the last key to put the next one there.
getter/setter pair
progress ↔ double
The same, as a fraction of duration — what a scrubber binds to.
getter/setter pair
rate ↔ double
Tempo. Takes effect from the next tick.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
status → MotionPlayerStatus
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
dispose() → void
Discards any resources used by the object.
override
finish() → void
Jump to the end pose and hold it — what stop is not: the fx stays.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
pause() → void
play() → void
Runs forward to the end. Resumes instead when paused, so a repeat survives a pause.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
repeat({int? times, bool yoyo = false}) → void
Runs times traversals of the timeline, or forever when null.
resume() → void
retarget(Playable next) → void
Continues this playback on next — the same motion bound to a fresh instance of the scene, which is what a token set that changed calls for: late final read its tokens once, so a mode is a new instance, and the intro that was halfway through should be halfway through on the new one too. The playhead keeps its place and its direction; the old playable is released and left at the pose it had.
reverse() → void
Runs backward to zero, from wherever the playhead is.
stop() → void
Cancel: the fx drops, the base was never touched, and the clock is at zero again — nothing plays, so a shader pass drawn by the clock shows the authored moment too.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited