【发布时间】:2021-11-02 05:55:57
【问题描述】:
我正在尝试通过 image_picker 从图库或相机中选择图像,并将图像保存在特定位置。当我从相机中选择图像时,我的代码可以完美运行,但是当我在保存时从图库中选择时,它会出现异常。这是我的代码
onPressed: () async {
final XFile? image = await picker.pickImage(source: ImageSource.gallery);
File tempFile = File(image.path);
tempFile = await tempFile.copy('storage/emulated/0/$image.name');
}
上面的代码通过异常
[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: FileSystemException: Cannot copy file to 'storage/emulated/0//6544578463230218846.jpg', path = '/data/user/0/com.example.nysu/cache/image_picker6544578463230218846.jpg' (OS Error: No such file or directory, errno = 2)
【问题讨论】:
标签: flutter filesystems imagepicker