asWidget method
Implementation
widget.Widget asWidget({
widget.Key? key,
Anchor anchor = Anchor.topLeft,
double angle = 0,
}) {
if (this is Future) {
return widget.FutureBuilder<Sprite>(
key: key,
future: this as Future<Sprite>,
builder: (context, data) {
if (!data.hasData) return const widget.SizedBox.shrink();
return widget.Container(
constraints: widget.BoxConstraints(
minWidth: data.data!.src.width,
minHeight: data.data!.src.height,
),
child: SpriteWidget(
sprite: data.data!,
anchor: anchor,
angle: angle,
),
);
},
);
}
return widget.Container(
key: key,
constraints: widget.BoxConstraints(
minWidth: (this as Sprite).src.width,
minHeight: (this as Sprite).src.height,
),
child: SpriteWidget(
sprite: this as Sprite,
anchor: anchor,
angle: angle,
),
);
}