我正在尝试创建一个具有圆形边缘但无法使角变圆的自定义容器。
我只想把绿色容器的角弄圆。
class MyPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
var paint = Paint()
..color = Colors.green.withOpacity(0.8)
..strokeWidth = 5
..strokeCap = StrokeCap.round;
final shapeBounds = Rect.fromLTRB(0, 0, size.width, size.height);
final path = Path()
..moveTo(shapeBounds.left + 10, shapeBounds.top) //3
..lineTo(shapeBounds.bottomLeft.dx + 10,shapeBounds.bottomLeft.dy)
..lineTo(shapeBounds.bottomRight.dx,shapeBounds.bottomRight.dy - size.height * 0.12)
..lineTo(shapeBounds.topRight.dx - 20,
shapeBounds.topRight.dy + size.height * 0.12) //7
..close();
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
// TODO: implement shouldRepaint
return false;
}
}