build method
Return widgets here that should be drawn as child(ren) of this widget You should also update the child(ren) and call the render of the child(ren)
Implementation
@override
FlameWidget build(BuildContext context) {
final paddingChild = (padding == null)
? child ?? FlameEmpty()
: FlamePadding(
child: child!,
padding: padding!,
);
final colorChild = (color == null && onUpdate == null)
? paddingChild
: FlameCanvas(
child: paddingChild,
onUpdate: onUpdate,
draw: (canvas, bounds, _) {
if (color != null) {
final colorPaint = Paint()
..color = color!
..style = PaintingStyle.fill;
canvas.drawRect(
Rect.fromLTWH(0, 0, bounds.x, bounds.y), colorPaint);
}
},
);
final sizedChild = (width == null && height == null)
? colorChild
: FlameSizedBox(
width: width,
height: height,
child: colorChild,
);
return sizedChild;
}