Skip to content

Instantly share code, notes, and snippets.

@divyanshub024
Created April 5, 2020 13:45
Show Gist options
  • Save divyanshub024/2b317c36f433c17852076237d9fc87dc to your computer and use it in GitHub Desktop.
Save divyanshub024/2b317c36f433c17852076237d9fc87dc to your computer and use it in GitHub Desktop.
class LinePainter extends CustomPainter {
final double progress;
LinePainter({this.progress});
Paint _paint = Paint()
..color = Colors.black
..strokeWidth = 4.0
..style = PaintingStyle.stroke
..strokeJoin = StrokeJoin.round;
@override
void paint(Canvas canvas, Size size) {
var path = Path();
path.moveTo(0, size.height / 2);
path.lineTo(size.width * progress, size.height / 2);
canvas.drawPath(path, _paint);
}
@override
bool shouldRepaint(LinePainter oldDelegate) {
return oldDelegate.progress != progress;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment