55 void paint(Canvas canvas, Size size) {
56 final center = Offset(size.width / 2, size.height - 20);
57 final radius = size.width * 0.45;
58 const startAngle = -5 * pi / 4;
59 const endAngle = pi / 4;
71 double currentAngle = startAngle;
72 final totalAngle = endAngle - startAngle;
73 const gapAngle = pi / 90;
75 for (
final segment in segments) {
77 ..
color = segment.color
78 ..style = PaintingStyle.stroke
80 ..strokeCap = StrokeCap.round;
82 final sweepAngle = (totalAngle * segment.percentage) - gapAngle;
85 Rect.fromCircle(center: center, radius: radius),
93 final dotPaint = Paint()
94 ..
color = segment.color
95 ..style = PaintingStyle.fill;
97 final angleForDot = currentAngle + sweepAngle;
98 final dotCenter = Offset(
99 center.dx + radius * cos(angleForDot),
100 center.dy + radius * sin(angleForDot),
103 canvas.drawCircle(dotCenter,
strokeWidth / 1.8, dotPaint);
105 currentAngle += sweepAngle + gapAngle;
109 if (segments.isNotEmpty) {
110 final lastSegment = segments.last;
111 final extraDotCenter = Offset(
112 center.dx + radius * cos(endAngle),
113 center.dy + radius * sin(endAngle) - 8,
119 Paint()..
color = lastSegment.color,
205 void paint(Canvas canvas, Size size) {
206 final center = Offset(size.width / 2, size.height);
207 final radius = size.height;
208 const startAngle = pi;
209 const sweepAngle = pi;
220 final bgPaint = Paint()
221 ..
color = Colors.grey[200]!
222 ..style = PaintingStyle.stroke
226 Rect.fromCircle(center: center, radius: radius),
234 final segmentAngle = sweepAngle / colors.length;
236 final progressAngle = sweepAngle *
progress;
239 var currentAngle = startAngle;
240 for (var i = 0; i < colors.length; i++) {
241 final paint = Paint()
243 ..style = PaintingStyle.stroke
245 ..strokeCap = StrokeCap.round;
247 final segEnd = currentAngle + segmentAngle;
248 final drawAngle = progressAngle - (startAngle - currentAngle);
252 Rect.fromCircle(center: center, radius: radius),
254 min(segmentAngle, drawAngle),
261 final dotPaint = Paint()
263 ..style = PaintingStyle.fill;
265 final dotPosition = Offset(
266 center.dx + radius * cos(currentAngle),
267 center.dy + radius * sin(currentAngle),
270 canvas.drawCircle(dotPosition, 6, dotPaint);
272 currentAngle = segEnd;