flutter - 无法在颤振中检索保存的图像(仅在 iOS 上可重现的问题)
问题描述
我正在使用 SQflite 保存图像,当我从头开始重新启动应用程序时,我无法再次找到图像文件。
以下是供您参考的代码。
File _storedImage;
Future<void> _takePicture() async {
final imageFile = await ImagePicker.pickImage(
source: ImageSource.gallery,
maxWidth: 600,
);
if (imageFile == null) {
return;
}
setState(() {
_storedImage = imageFile;
});
final appDir = await syspaths.getApplicationDocumentsDirectory();
final fileName = path.basename(imageFile.path);
final savedImage = await imageFile.copy('${appDir.path}/$fileName');
widget.onSelectImage(savedImage);
}
以下是供您参考的异常详细信息。
════════ Exception caught by image resource service ════════════════════════════
The following FileSystemException was thrown resolving an image codec:
Cannot open file, path = '/Users/*****/Library/Developer/CoreSimulator/Devices/C561CB20-67D1-4188-996C-8B06CFB483A9/data/Containers/Data/Application/0A5D4A4F-3B4B-41E5-AFBA-B1A99C2CBFDB/Documents/image_picker_6231C3D6-D4D4-4962-861B-0792D42D2C24-78611-000007A4CC408DD4.jpg' (OS Error: No such file or directory, errno = 2)
When the exception was thrown, this was the stack
#0 _File.open.<anonymous closure> (dart:io/file_impl.dart:364:9)
(elided 13 frames from package dart:async)
Path: /Users/*****/Library/Developer/CoreSimulator/Devices/C561CB20-67D1-4188-996C-8B06CFB483A9/data/Containers/Data/Application/0A5D4A4F-3B4B-41E5-AFBA-B1A99C2CBFDB/Documents/image_picker_6231C3D6-D4D4-4962-861B-0792D42D2C24-78611-000007A4CC408DD4.jpg
解决方案
Xcode 更新似乎已经解决了这个问题!不过很奇怪:-P
感谢你们所有人,他们试图找到解决方案:)
推荐阅读
- python - 如何在python中计算列表或数组的单调性值
- angular - 使用 Angular 显示 JSON 文件中的数据
- javascript - 如何仅对一个孩子进行排序
- javascript - Javascript 未设置 Cookie
- java - JAVA_HOME 无法运行 gradlew build(用于合金模型检查器)
- python - 如何用同一个列表初始化两个列表类型的属性?
- datetime - 烧瓶将日期时间计算添加到数据库中
- python - 导入错误:使用 pickle.load 时没有名为“utils”的模块
- android - 在 Android 中使用 React 本机钥匙串进行人脸身份验证
- c# - ASP.NET Core - 可配置路由