drawObject method
Draws the arrow on the provided canvas
of size size
.
Implementation
@override
void drawObject(Canvas canvas, Size size) {
final arrowHeadSize = _arrowHeadSize;
final dx = length / 2 * scale - arrowHeadSize;
final start = position.translate(-length / 2 * scale, 0);
final end = position.translate(dx, 0);
if ((end - start).dx > 0) canvas.drawLine(start, end, paint);
final pathDx = dx /*.clamp(-arrowHeadSize/2, double.infinity)*/;
final path = Path();
path.moveTo(position.dx + pathDx + arrowHeadSize, position.dy);
path.lineTo(position.dx + pathDx, position.dy - (arrowHeadSize / 2));
path.lineTo(position.dx + pathDx, position.dy + (arrowHeadSize / 2));
path.lineTo(position.dx + pathDx + arrowHeadSize, position.dy);
final headPaint = paint.copyWith(
style: PaintingStyle.fill,
);
canvas.drawPath(path, headPaint);
}