SpriteAnimationWidget.asset constructor
SpriteAnimationWidget.asset({
- required String path,
- required SpriteAnimationData data,
- Images? images,
- bool playing = true,
- Anchor anchor = Anchor.topLeft,
- WidgetBuilder? errorBuilder,
- WidgetBuilder? loadingBuilder,
- VoidCallback? onComplete,
- Paint? paint,
- Size? size,
- String? package,
- Key? key,
Loads image from the asset path and renders it as a widget.
It will use the loadingBuilder while the image from path is loading.
To render without loading, or when you want to have a gapless playback
when the path value changes, consider loading the SpriteAnimation
beforehand and direct pass it to the default constructor.
The path is the full path of the asset, as declared in the
pubspec.yaml, for example assets/images/player.png.
Implementation
SpriteAnimationWidget.asset({
required String path,
required SpriteAnimationData data,
Images? images,
this.playing = true,
this.anchor = Anchor.topLeft,
this.errorBuilder,
this.loadingBuilder,
this.onComplete,
this.paint,
this.size,
String? package,
super.key,
}) : _animationFuture = SpriteAnimation.load(
path,
data,
images: images,
package: package,
),
_animationTicker = null;