【发布时间】:2021-03-05 13:39:14
【问题描述】:
在我的 Flutter 应用程序中使用 image_cropper 插件后,我收到此错误:
Unable to load asset: /data/user/0/com.habbyt.version1/cache/image_cropper_1606070878133.jpg
When the exception was thrown, this was the stack
#0 PlatformAssetBundle.load
<asynchronous suspension>
这是我裁剪图像的代码:
_cropImage(filePath) async {
File croppedImage = await ImageCropper.cropImage(
sourcePath: filePath,
aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1),
maxWidth: 1080,
maxHeight: 1080,
);
if (croppedImage != null) {
setState(() {
_image = croppedImage;
imageExists = true;
});
}
}
我使用 AssetImage(_image.path) 可视化图像。
此错误仅在我启动模拟器后发生。一旦我进行一次热重载,我就可以看到图像,它显示正确,并且我再也不会收到此错误。但是一旦我重新启动模拟器,错误就会再次发生。 我也在真机上测试过,一直报错。
知道可能是什么问题吗?
【问题讨论】: