SpriteWidget.asset constructor

SpriteWidget.asset({
  1. required String path,
  2. Images? images,
  3. Anchor anchor = Anchor.topLeft,
  4. double angle = 0,
  5. Vector2? srcPosition,
  6. Vector2? srcSize,
  7. WidgetBuilder? errorBuilder,
  8. WidgetBuilder? loadingBuilder,
  9. Key? key,
})

Load the 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 image beforehand and direct pass it to the default constructor.

Implementation

SpriteWidget.asset({
  required String path,
  Images? images,
  this.anchor = Anchor.topLeft,
  this.angle = 0,
  Vector2? srcPosition,
  Vector2? srcSize,
  this.errorBuilder,
  this.loadingBuilder,
  super.key,
}) : _spriteFuture = Sprite.load(
        path,
        srcSize: srcSize,
        srcPosition: srcPosition,
        images: images,
      );