render method
void
render(})
override
Renders a given text
in a given position position
using the provided
canvas
and anchor
.
For example, if Anchor.center is specified, it's going to be drawn
centered around position
.
Example usage (Using TextPaint implementation):
const TextStyle style = TextStyle(fontSize: 48.0, fontFamily: 'Arial'); const TextPaint textPaint = TextPaint(style: style); textPaint.render( canvas, Vector2(size.x - 10, size.y - 10, anchor: Anchor.bottomRight, );
Implementation
@override
void render(
Canvas canvas,
String text,
Vector2 p, {
Anchor anchor = Anchor.topLeft,
}) {
final tp = toTextPainter(text);
final translatedPosition = anchor.translate(p, tp.size.toVector2());
tp.paint(canvas, translatedPosition.toOffset());
}