Skip to content

Instantly share code, notes, and snippets.

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 ValeryPonomarenko/ad811f4ae917f9601e0fa9d464c07c4f to your computer and use it in GitHub Desktop.
Save ValeryPonomarenko/ad811f4ae917f9601e0fa9d464c07c4f to your computer and use it in GitHub Desktop.
@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