import 'package:flutter/material.dart'; class BgPainter extends CustomPainter { final double bezierHeight; final Color bgColor ; BgPainter({ this.bezierHeight = 10, this.bgColor = Colors.white, }); @override void paint(Canvas canvas, Size size) { Path path = Path(); //移动到点 P0点 也是曲线的起点 path.lineTo(0, 0); path.lineTo(size.width, 0); path.lineTo(size.width, size.height - bezierHeight); path.quadraticBezierTo(size.width / 2.0, size.height, 0, size.height - bezierHeight); path.close(); Paint paint = Paint() ..color = bgColor ..style = PaintingStyle.fill; canvas.drawPath(path, paint); } @override bool shouldRepaint(covariant CustomPainter oldDelegate) => false; }