【发布时间】:2020-07-27 23:12:59
【问题描述】:
我正在尝试创建一个具有圆形边缘但无法使角变圆的自定义容器。 我只想把绿色容器的角弄圆。
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;
}
}
【问题讨论】:
-
你可以看这里并摆弄它:stackoverflow.com/questions/50211863/…
-
你找到解决这个案子的办法了吗?
标签: flutter dart paint custom-painting