首页 > 解决方案 > 无法在颤振中检索保存的图像(仅在 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

标签: flutterflutter-dependencies

解决方案


Xcode 更新似乎已经解决了这个问题!不过很奇怪:-P

感谢你们所有人,他们试图找到解决方案:)


推荐阅读