paint method
Paints the particle at the given position along the connection path.
Parameters:
canvas: The canvas to draw onposition: The center position of the particletangent: The path tangent at this position (for directional particles)basePaint: The base paint from the connection (color, style, etc.)
Implementation
@override
void paint(Canvas canvas, Offset position, Tangent tangent, Paint basePaint) {
final textPainter = TextPainter(
text: TextSpan(
text: character,
style: TextStyle(fontSize: fontSize, color: color ?? basePaint.color),
),
textAlign: TextAlign.center,
textDirection: TextDirection.ltr,
);
textPainter.layout();
// Center the text at the position
final offset = Offset(
position.dx - textPainter.width / 2,
position.dy - textPainter.height / 2,
);
textPainter.paint(canvas, offset);
}