SpriteWidget.asset constructor
SpriteWidget.asset({})
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.
The path is the full path of the asset, as declared in the
pubspec.yaml, for example assets/images/player.png.
Implementation
SpriteWidget.asset({
required String path,
Images? images,
this.anchor = Anchor.topLeft,
this.angle = 0,
Vector2? srcPosition,
Vector2? srcSize,
this.errorBuilder,
this.loadingBuilder,
this.paint,
this.rasterize = false,
this.size,
String? package,
super.key,
}) : _spriteFuture = Sprite.load(
path,
srcSize: srcSize,
srcPosition: srcPosition,
images: images,
package: package,
);