我正在使用 Crop 0.5.0 包来裁剪从我的应用作为 PickedFile 传递的图像。
裁剪器本身工作正常,我按预期显示和裁剪图像。对于旅程的最后一部分,我不想将图像保存到设备(如裁剪包文档示例中指定的那样),而是想将“裁剪”的图像文件(或任何可能的格式)返回到我的上传页面(它的位置)然后上传到 Firebase 存储)。
为了实现这一点,我创建了一个回调函数:
void _openImageCropper(
BuildContext context, int index, PickedFile _imageFile) async {
final Image croppedImageRetrunValue = await Navigator.push(context,
MaterialPageRoute(builder: (_) => ImageCropperView(image: _imageFile)),
);
从裁剪器屏幕返回值的最后一个函数是:
void _cropImage() async {
final pixelRatio = MediaQuery.of(context).devicePixelRatio;
final cropped = await controller.crop(pixelRatio: pixelRatio);
Navigator.pop(context, cropped);
}
我得到的错误是:Error: Expected a value of type 'Image?', but got one of type 'CkImage'
并且只是为了澄清我在网络上使用 Flutter。
我想一种简化问题的方法是返回裁剪后的图像的最佳方法是什么?