SpriteStudioAnimation class
Layer 4 — an animation you place, with nothing to own.
SpriteStudioView is the adapter: it draws a SpriteStudioPlayer that the
caller built, loaded, drove and disposed. That is the right shape for a
screen that already has a player — one it shares with a
SpriteStudioPartAnchor, swaps animations on from a state machine, or ticks
from its own clock. It is the wrong shape for putting one animation on the
screen, which took a StatefulWidget, a SingleTickerProviderStateMixin, an
initState, an async _init, and a dispose before anything moved.
This widget is that boilerplate, once:
SpriteStudioAnimation.asset('assets/overall/Basic.ssab')
It owns the player it builds — the ticker, the load, and the disposal — and rebuilds it when assetKey, bundle or backend change. Reach the player through onPlayerCreated when you need the rest of the L3 surface; graduate to SpriteStudioView when you want to own its lifetime instead.
Every other parameter reaches the player only when it changes. A call made on the player through onPlayerCreated therefore stands until the matching parameter changes, rather than being put back on the next rebuild.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- SpriteStudioAnimation
Constructors
-
SpriteStudioAnimation.asset(String assetKey, {Key? key, String? animation, Duration transition = Duration.zero, double? width, double? height, BoxFit fit = BoxFit.contain, AlignmentGeometry alignment = Alignment.center, Rect? frame, int loopCount = -1, bool playing = true, double speedScale = 1.0, bool flipX = false, bool flipY = false, Offset offset = Offset.zero, double scale = 1.0, AssetBundle? bundle, SpriteStudioBackend backend = SpriteStudioBackend.auto, Widget? placeholder, void onLoaded(SpriteStudioPlayer player)?, void onError(Object error, StackTrace stackTrace)?, void onPlayerCreated(SpriteStudioPlayer player)?, VoidCallback? onAnimationStarted, VoidCallback? onAnimationFinished, VoidCallback? onAnimationLooped, SsUserDataCallback? onUserData, SsSignalCallback? onSignal, SsAudioCallback? onAudio, List<
Widget> children = const <Widget>[]}) -
Plays
assetKeyfrom the asset bundle.const
Properties
- alignment → AlignmentGeometry
-
Which point of the canvas lands on the matching point of the box. Passed
to SpriteStudioView.
final
- animation → String?
-
Which animation to select, or null for the pack's first.
final
- assetKey → String
-
The
.ssab's key in the asset bundle. Reference textures resolve from the key's own folder, so the converter's output directory works as it stands.final - backend → SpriteStudioBackend
-
Which render backend the player draws with.
final
- bundle → AssetBundle?
-
Which bundle to read assetKey from. Null is
rootBundle.final -
children
→ List<
Widget> -
Widgets laid over the animation, each covering exactly its box — where a
SpriteStudioPartAnchor goes to follow a part:
final
- fit → BoxFit
-
How the canvas is scaled into the box —
contain(the default),coverornone. Passed to SpriteStudioView.final - flipX → bool
-
Mirrors the drawn animation horizontally. See SpriteStudioPlayer.flipX.
final
- flipY → bool
-
Mirrors the drawn animation vertically. See SpriteStudioPlayer.flipY.
final
- frame → Rect?
-
A box to fit instead of the authored canvas, in player-local pixels.
Passed to SpriteStudioView.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double?
-
Passed to SpriteStudioView. Null takes it from the authored canvas.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loopCount → int
-
-1loops forever,n > 0plays n times. Applied before playback starts.final - offset → Offset
-
Shifts the drawn animation after the fit. See SpriteStudioPlayer.offset.
final
- onAnimationFinished → VoidCallback?
-
Fired once every configured loop has played. See
SpriteStudioPlayer.onAnimationFinished.
final
- onAnimationLooped → VoidCallback?
-
Fired each time playback crosses a loop boundary. See
SpriteStudioPlayer.onAnimationLooped.
final
- onAnimationStarted → VoidCallback?
-
Fired when playback heads out — including the start this widget issues
once the pack loads, which comes before onLoaded. See
SpriteStudioPlayer.onAnimationStarted.
final
- onAudio → SsAudioCallback?
-
Fired for each audio key the playhead crosses; playing the sound is the
app's job. See SpriteStudioPlayer.onAudio.
final
- onError → void Function(Object error, StackTrace stackTrace)?
-
Called when the load fails, instead of the error reaching the zone as an
unhandled async error. The widget then keeps showing placeholder.
final
- onLoaded → void Function(SpriteStudioPlayer player)?
-
Called once the pack is loaded, the animation selected and, while
playing, playback started — the moment placeholder gives way to the
first drawable frame.
final
- onPlayerCreated → void Function(SpriteStudioPlayer player)?
-
Handed the player as soon as it exists, before the load, for settings that
can go on ahead of it. What needs the pack — part overrides, tracks, texture
replacement, transport — goes in onLoaded. Do not dispose it; this widget
does.
final
- onSignal → SsSignalCallback?
-
Fired for each active signal the playhead crosses. See
SpriteStudioPlayer.onSignal.
final
- onUserData → SsUserDataCallback?
-
Fired for each user-data key the playhead crosses. See
SpriteStudioPlayer.onUserData.
final
- placeholder → Widget?
-
Shown until the first frame can be drawn — the pack loaded and its textures
decoded.
final
- playing → bool
-
Whether the animation advances. On by default.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scale → double
-
Multiplies the fit's scale. See SpriteStudioPlayer.scale.
final
- speedScale → double
-
Playback rate as a multiple of the authored one. See
SpriteStudioPlayer.speedScale.
final
- transition → Duration
-
How long a change of animation crossfades for; zero, the default,
switches at once.
final
- width → double?
-
Passed to SpriteStudioView. Null takes it from the authored canvas, as
Imagedoes from its picture.final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< SpriteStudioAnimation> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
playerOf(
BuildContext context) → SpriteStudioPlayer? -
The player of the nearest SpriteStudioAnimation above
context— what a widget in its children reaches it by — or null when there is none.