draw method
- @override
- Canvas canvas
override
Implementation
@override
void draw(Canvas canvas) {
final textPainter = TextPainter(
text: TextSpan(
text: text,
style: TextStyle(color: color, fontSize: 14.0),
),
textDirection: TextDirection.ltr,
)..layout(maxWidth: rect.width);
double dx = rect.left;
if (halign == 'center') {
dx += (rect.width - textPainter.width) / 2;
} else if (halign == 'right') {
dx += rect.width - textPainter.width;
}
double dy = rect.top;
if (valign == 'center') {
dy += (rect.height - textPainter.height) / 2;
} else if (valign == 'bottom') {
dy += rect.height - textPainter.height;
}
textPainter.paint(canvas, Offset(dx, dy));
}