SpriteAnimationWidget.asset constructor

SpriteAnimationWidget.asset({
  1. required String path,
  2. required SpriteAnimationData data,
  3. Images? images,
  4. bool playing = true,
  5. Anchor anchor = Anchor.topLeft,
  6. WidgetBuilder? errorBuilder,
  7. WidgetBuilder? loadingBuilder,
  8. VoidCallback? onComplete,
  9. Paint? paint,
  10. Size? size,
  11. String? package,
  12. 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;