上次,我是在自定义油漆的帮助下绘制这个形状的,请看一下,它可能对你有帮助
//Create a custom painter class
class MyCustomPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
Paint paint_0 = new Paint()
..color = Colors.white
..style = PaintingStyle.fill
..strokeWidth = 1;
Path path_0 = Path();
path_0.moveTo(size.width * 0.1250000, size.height * 0.7500000);
path_0.quadraticBezierTo(size.width * 0.0630125, size.height * 0.7507750,
size.width * 0.0625000, size.height * 0.6250000);
path_0.quadraticBezierTo(size.width * 0.0625000, size.height * 0.3437500,
size.width * 0.0625000, size.height * 0.2500000);
path_0.quadraticBezierTo(size.width * 0.0629875, size.height * 0.1260000,
size.width * 0.1250000, size.height * 0.1250000);
path_0.quadraticBezierTo(size.width * 0.6875000, size.height * 0.1250000,
size.width * 0.8750000, size.height * 0.1250000);
path_0.quadraticBezierTo(size.width * 0.9370375, size.height * 0.1259250,
size.width * 0.9375000, size.height * 0.2500000);
path_0.lineTo(size.width * 0.9375000, size.height * 0.6250000);
path_0.quadraticBezierTo(size.width * 0.9370250, size.height * 0.7490750,
size.width * 0.8750000, size.height * 0.7500000);
path_0.quadraticBezierTo(size.width * 0.8125000, size.height * 0.7500000,
size.width * 0.6250000, size.height * 0.7500000);
path_0.quadraticBezierTo(size.width * 0.5259125, size.height * 0.9124000,
size.width * 0.5000000, size.height * 0.9462750);
path_0.quadraticBezierTo(size.width * 0.4749750, size.height * 0.9035750,
size.width * 0.3750000, size.height * 0.7500000);
path_0.quadraticBezierTo(size.width * 0.3125000, size.height * 0.7500000,
size.width * 0.1250000, size.height * 0.7500000);
path_0.close();
canvas.drawPath(path_0, paint_0);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return true;
}
}
像这样使用
CustomPaint(
size: Size(width, 400),
painter: MyCustomPainter(),
)
结果: