You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
778 B
36 lines
778 B
|
|
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; |
|
|
|
} |