Skip to content

Instantly share code, notes, and snippets.

@ravindu9701
Last active August 4, 2020 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravindu9701/01a6f5127851351d925370f3d9037f6e to your computer and use it in GitHub Desktop.
Save ravindu9701/01a6f5127851351d925370f3d9037f6e to your computer and use it in GitHub Desktop.
class DrawingPainter extends CustomPainter {
final List<Offset> points;
DrawingPainter(this.points);
final Paint _paint = Paint()
..strokeCap = StrokeCap.round
..color = Colors.blue
..strokeWidth = Constants.strokeWidth;
@override
void paint(Canvas canvas, Size size) {
for (int i = 0; i < points.length - 1; i++) {
if (points[i] != null && points[i + 1] != null) {
canvas.drawLine(points[i], points[i + 1], _paint);
}
}
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment