File? imageFile;
ImagePicker imagePicker = ImagePicker();
Future\<File?\> getImage(ImageSource imageSource) async {
final XFile? pickedFile = await imagePicker.pickImage(source: imageSource);
if (pickedFile == null) {
return null;
}
return File(pickedFile.path);
}
// source is camera
// save to SharedPreferences
final String duplicateFilePath = await getApplicationDocumentsDirectory().then((value) =\> value.path);
final fileName = basename(file.path);
final File newImage = await file.copy('$duplicateFilePath/$fileName');
// save newImage.path
重新启动应用后,当我try 加载图像时,遇到以下错误: 解析图像编解码器时引发以下PathNotFoundException: 无法检索文件的长度,路径="/var/mobile/Containers/Data/Application/7D7645C5—CAF6—43F5—A484—CA93872D2996/Documents/image_picker_46D51663—C51D—4DA6—B350—57C79EFAC368—3158—0000333318B1CCD.jpg"(操作系统错误:没有这样的文件或目录,errno = 2)
有什么问题吗?这个问题只有iOS而不是Android