onLoad method

  1. @override
Future<void> onLoad()

Loads the button's components (background and text).

Implementation

@override
Future<void> onLoad() async {
  background = RectangleComponent(
    size: size,
    paint: Paint()..color = currentColor,
  );

  text = TextComponent(
    text: label,
    anchor: Anchor.center,
    position: size / 2,
    textRenderer: TextPaint(style: TextStyle(color: textColor, fontSize: 10)),
  );

  addAll([background, text]);
}