drawObject method

  1. @override
void drawObject(
  1. Canvas canvas,
  2. Size size
)
override

Draws the text on the provided canvas of size size.

Implementation

@override
void drawObject(Canvas canvas, Size size) {
  // Render the text according to the size of the canvas taking the scale in mind
  textPainter.layout(maxWidth: size.width * scale);

  // Paint the text on the canvas
  // It is shifted back by half of its width and height to be drawn in the center
  textPainter.paint(canvas,
      position - Offset(textPainter.width / 2, textPainter.height / 2));
}