draw method
void
draw()
override
Implementation
@override
void draw(Canvas canvas, Size size, double scaleX, double scrollX,
double Function(double) getX, double Function(double) getY) {
if (xPosition == null) return;
final paint = Paint()
..color = color.withOpacity(state == DrawingToolState.drawing ? 0.6 : 1.0)
..strokeWidth = strokeWidth
..style = PaintingStyle.stroke;
// 如果是预览状态,绘制虚线效果
if (state == DrawingToolState.drawing) {
_drawDashedLine(canvas, Offset(xPosition!, 0),
Offset(xPosition!, size.height), paint);
} else {
canvas.drawLine(
Offset(xPosition!, 0),
Offset(xPosition!, size.height),
paint,
);
}
}