简体   繁体   English

如何在 flutter 中使用 file_picker package 获取实际文件路径

[英]How to get actual file path with file_picker package in flutter

I wanted to delete a file from device storage after receiving the file path from file_picker.从 file_picker 收到文件路径后,我想从设备存储中删除文件。 but the problem is file_picker returns a path of a temporary copy of the file from the application's directory.但问题是 file_picker 从应用程序目录返回文件临时副本的路径。 Is there a way to get the actual path of the file file_picker picks?有没有办法获取文件 file_picker 选择的实际路径?

For image_picker对于 image_picker

var pickedImage = await _picker.getImage(source: ImageSource.gallery, imageQuality: 25);
File image = File(pickedImage.path);

for file_picker对于文件选择器

FilePickerResult res = await FilePicker.platform.pickFiles();
File image = File(res.files.first.path);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM