1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
class WheelView extends CustomPainter { @override void paint(Canvas canvas, Size size) { double wheelSize = min(size.width, size.height) / 2; double count = 6; double radius = 2 * pi / count; Rect rect = Rect.fromCircle( center: Offset(wheelSize, wheelSize), radius: wheelSize); canvas.drawArc(rect, 0, radius, true, getPaint(Colors.orange)); canvas.drawArc(rect, radius, radius, true, getPaint(Colors.black38)); canvas.drawArc(rect, radius * 2, radius, true, getPaint(Colors.green)); canvas.drawArc(rect, radius * 3, radius, true, getPaint(Colors.red)); canvas.drawArc(rect, radius * 4, radius, true, getPaint(Colors.blue)); canvas.drawArc(rect, radius * 5, radius, true, getPaint(Colors.pink)); }
@override bool shouldRepaint(covariant CustomPainter oldDelegate) => oldDelegate != this;
Paint getPaint(Color color) { Paint paint = Paint(); paint.color = color; return paint; } }
|