Created
June 4, 2019 17:19
-
-
Save JorgeCastilloPrz/b19b6e03e2c11d3cc3c4f814756ce8ce to your computer and use it in GitHub Desktop.
Complete Paint method.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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