//首先是我写的代码。
class AreaPainter extends CustomPainter{
List<Offset> points;
bool clear;
bool iscrop;
final ui.Image image;
BuildContext context;
AreaPainter(@required this.image,@required this.clear,@required this.points,@required `this.iscrop,@required this.context);`
@override
void paint(Canvas canvas, Size size) async {
final paint = Paint()
..color = Colors.blue
..strokeCap = StrokeCap.square
..style = PaintingStyle.fill
..strokeWidth = 2;
final ui.Rect rect = ui.Offset.zero & size;
final Size imageSize = new Size(image.width.toDouble(), image.height.toDouble());
FittedSizes sizes = applyBoxFit(BoxFit.cover, imageSize, size);
// if you don't want it centered for some reason change this.
final Rect …Run Code Online (Sandbox Code Playgroud)