paint method
Paints the given paths
onto the canvas
.
canvas
The canvas to draw on.
size
The size of the canvas.
paths
A list of CubicPath objects representing the signature to be drawn.
Implementation
@override
void paint(Canvas canvas, Size size, List<CubicPath> paths) {
final paint = Paint()
..color = color
..strokeWidth = 0.0; // Stroke width is handled by the shape path itself
for (final path in paths) {
if (path.isFilled) {
if (path.isDot) {
// If it's a dot, draw a circle
canvas.drawCircle(path.lines[0], path.lines[0].startRadius(width, maxWidth), paint);
} else {
// Otherwise, draw the filled shape path
canvas.drawPath(PathUtil.toShapePath(path.lines, width, maxWidth), paint);
// Draw circles at the start and end of the path for a smoother look
final first = path.lines.first;
final last = path.lines.last;
canvas.drawCircle(first.start, first.startRadius(width, maxWidth), paint);
canvas.drawCircle(last.end, last.endRadius(width, maxWidth), paint);
}
}
}
}