asWidget method
Implementation
widget.Widget asWidget({
widget.Key? key,
bool playing = true,
Anchor anchor = Anchor.topLeft,
}) {
if (this is Future) {
return widget.FutureBuilder<SpriteAnimation>(
key: key,
future: this as Future<SpriteAnimation>,
builder: (context, data) {
if (!data.hasData) return const widget.SizedBox.shrink();
return widget.Container(
constraints: widget.BoxConstraints(
minWidth: data.data!.frames.first.sprite.src.width,
minHeight: data.data!.frames.first.sprite.src.height,
),
child: SpriteAnimationWidget(
animation: data.data!,
animationTicker: data.data!.createTicker(),
playing: playing,
anchor: anchor,
),
);
},
);
}
return widget.Container(
key: key,
constraints: widget.BoxConstraints(
minWidth: (this as SpriteAnimation).frames.first.sprite.src.width,
minHeight: (this as SpriteAnimation).frames.first.sprite.src.height,
),
child: SpriteAnimationWidget(
animation: this as SpriteAnimation,
animationTicker: (this as SpriteAnimation).createTicker(),
playing: playing,
anchor: anchor,
),
);
}