SpriteButton.asset constructor
SpriteButton.asset({
- required String path,
- required String pressedPath,
- required void onPressed()?,
- required double width,
- required double height,
- Widget? label,
- Images? images,
- Vector2? srcPosition,
- Vector2? srcSize,
- Vector2? pressedSrcPosition,
- Vector2? pressedSrcSize,
- String? disabledPath,
- Vector2? disabledSrcPosition,
- Vector2? disabledSrcSize,
- EdgeInsets pressedInsets = const EdgeInsets.only(top: 5),
- WidgetBuilder? errorBuilder,
- WidgetBuilder? loadingBuilder,
- String? package,
- Key? key,
Loads the images from the asset path and pressedPath 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. When a package
is given, the paths are resolved relative to that package's assets.
Implementation
SpriteButton.asset({
required String path,
required String pressedPath,
required this.onPressed,
required this.width,
required this.height,
this.label,
Images? images,
this.srcPosition,
this.srcSize,
this.pressedSrcPosition,
this.pressedSrcSize,
String? disabledPath,
this.disabledSrcPosition,
this.disabledSrcSize,
this.pressedInsets = const EdgeInsets.only(top: 5),
this.errorBuilder,
this.loadingBuilder,
String? package,
super.key,
}) : _buttonsFuture = _loadButtons(
images: images ?? Flame.images,
package: package,
path: path,
srcPosition: srcPosition,
srcSize: srcSize,
pressedPath: pressedPath,
pressedSrcPosition: pressedSrcPosition,
pressedSrcSize: pressedSrcSize,
disabledPath: disabledPath,
disabledSrcPosition: disabledSrcPosition,
disabledSrcSize: disabledSrcSize,
);