drawObject method
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));
}