[英]Flutter Image Cropper unable to load asset
為我的 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) 可視化圖像。
此錯誤僅在我啟動模擬器后發生。 一旦我進行一次熱重載,我就可以看到圖像,它顯示正確,而且我再也不會出現此錯誤。 但是一旦我重新啟動模擬器,錯誤就會再次發生。 我還在真實設備上對其進行了測試,錯誤不斷發生。
知道可能是什么問題嗎?
有同樣的問題。
我的修復:
老的
final ByteData bytes = await rootBundle.load(filePath);
新的
final ByteData bytes= file.readAsBytesSync().buffer.asByteData()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.