draw method

  1. @override
void draw(
  1. Canvas canvas,
  2. Size boardSize
)
override

Implementation

@override
void draw(Canvas canvas, Size boardSize) {
  super.draw(canvas, boardSize);

  if (!_isEditing) {
    final textSpan = TextSpan(
      text: text,
      style: makeAdaptive ? textStyle.copyWith(
        fontSize: (8 + (size.width/10).round()).toDouble(),
      ) : textStyle,
    );
    final textPainter = TextPainter(
      text: textSpan,
      textDirection: TextDirection.ltr,
      textAlign: textAlign,
    );
    textPainter.layout(
      minWidth: size.width,
      maxWidth: size.width,
    );

    final offsetRect = Alignment.center.inscribe(
      textPainter.size,
      Rect.fromPoints(
        location,
        location.translate(size.width, size.height),
      ),
    );
    textPainter.paint(canvas, offsetRect.topLeft.translate(-1.5, 0));
  }
}