Created
October 16, 2022 19:05
-
-
Save ValeryPonomarenko/56ec497743f951630f3be47b91ce95ad 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)); | |
var radius = startBarRadius; | |
for (var layer = 0; layer < layers; layer++) { | |
final lengthOfHalfCircle = pi * radius; | |
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; | |
} | |
radius += _dotDiameter + layersSpacing; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment