paint method
Paints the text onto the given canvas at the given offset.
Valid only after layout has been called.
If you cannot see the text being painted, check that your text color does not conflict with the background on which you are drawing. The default text color is white (to contrast with the default black background color), so if you are writing an application with a white background, the text will not be visible by default.
To set the text style, specify a TextStyle when creating the TextSpan that you pass to the TextPainter constructor or to the text property.
Implementation
void paint(Canvas canvas, Offset offset) {
assert(() {
if (_needsLayout) {
throw FlutterError(
'TextPainter.paint called when text geometry was not yet calculated.\n'
'Please call layout() before paint() to position the text before painting it.'
);
}
return true;
}());
canvas.drawParagraph(_paragraph, offset);
}