Skip to content

Instantly share code, notes, and snippets.

@JorgeCastilloPrz
Created June 4, 2019 17:19
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 JorgeCastilloPrz/b19b6e03e2c11d3cc3c4f814756ce8ce to your computer and use it in GitHub Desktop.
Save JorgeCastilloPrz/b19b6e03e2c11d3cc3c4f814756ce8ce to your computer and use it in GitHub Desktop.
Complete Paint method.
class ArcPainter extends CustomPainter {
// ...
@override
void paint(Canvas canvas, Size size) {
if (backgroundColor != null) {
final Paint backgroundPaint = Paint()
..color = backgroundColor
..strokeWidth = strokeWidth
..style = PaintingStyle.stroke;
canvas.drawArc(
Offset(-strokeWidth / 2, -strokeWidth / 2) &
Size(size.width + strokeWidth, size.height + strokeWidth),
0,
_completeCircumference,
false,
backgroundPaint);
}
final Paint paint = Paint()
..color = color
..strokeWidth = strokeWidth
..style = PaintingStyle.stroke
..strokeCap = StrokeCap.square;
canvas.drawArc(
Offset(-strokeWidth / 2, -strokeWidth / 2) &
Size(size.width + strokeWidth, size.height + strokeWidth),
arcStart,
arcSweep,
false,
paint);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment