Last active
October 16, 2022 19:05
-
-
Save ValeryPonomarenko/ad811f4ae917f9601e0fa9d464c07c4f to your computer and use it in GitHub Desktop.
This file contains 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
@override | |
void paint(Canvas canvas, Size size) { | |
final center = size.bottomCenter(Offset(0, -dotRadius)); | |
final lengthOfHalfCircle = pi * startBarRadius; | |
final dotsNumber = (lengthOfHalfCircle / _dotsSizeWithSpacing).floor(); | |
final angleStep = _halfCircle / (dotsNumber - 1); | |
var angle = _startAngle; | |
final progressItems = (dotsNumber * progress).toInt(); | |
for (var dot = 0; dot < dotsNumber; dot++) { | |
final radian = pi * 2 * angle / _circle; | |
canvas.drawCircle( | |
Offset( | |
radius * sin(radian) + center.dx, | |
radius * cos(radian) + center.dy, | |
), | |
dotRadius, | |
dot < progressItems ? _progressPaint : _paint, | |
); | |
angle -= angleStep; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment