chip method
void
chip()
Implementation
void chip() async {
final data = editorKey.currentState?.rawImageData;
final cropRect = editorKey.currentState?.getCropRect();
final nav = Navigator.of(context);
if(data==null || cropRect ==null){
nav.pop();
return;
}
image.Image? src = image.decodeImage(data);
if(src==null){
nav.pop();
return;
}
//image: 4.x 版本
// src = image.copyCrop(src, x: cropRect.left.toInt(), y: cropRect.top.toInt(),
// width: cropRect.width.toInt(), height: cropRect.height.toInt());
// image: 3.x 版本
// src = image.copyCrop(src, cropRect.left.toInt(), cropRect.top.toInt(), cropRect.width.toInt(), cropRect.height.toInt());
final byts = image.encodeJpg(src , quality: 80);
final hz = currPath.lastIndexOf('.'); // 图片后缀
final wpa = '${currPath.substring(0,hz)}${DateTime.now().toIso8601String().replaceAll(" ", '')}';
final path = '$wpa.${currPath.split('.').last}';
final file = await io.File(path).create();
final file1 = await file.writeAsBytes(byts);
nav.pop(file1);
}