我需要创建一个如下的弧形图:
使用画布我已经创建了这个:
我的代码:
class CustomChartPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
Rect drawingRect = Rect.fromCircle(center: Offset(size.width / 2, size.height / 2), radius: size.width / 2);
final Paint paint2 = Paint();
paint2.color = const Color.fromRGBO(0, 0, 0, 0.04);
paint2.style = PaintingStyle.stroke;
paint2.strokeWidth = 50;
canvas.drawCircle(Offset(size.width / 2, size.height / 2), size.width / 2, paint2);
canvas.drawArc(drawingRect,
-pi / 2 + 0.35,
pi - 0.35,
false,
greenPaint);
canvas.drawArc(drawingRect,
pi / 2 + 0.35,
pi - 0.35,
false,
orangePaint);
}
}
如何如第一张图片所示倒圆弧的边缘?
答案 0 :(得分:4)
如@pskink所述,解决方案是使用Paint.strokeCap
,更准确地说是:paint.strokeCap = StrokeCap.round