Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File_Picker plugin doesn't return absolute path for write file in Flutter

I'm using the file_picker plugin to pick files from device storage in my flutter app. I need an absolute path so that I can read/write files. But picking file using file_picker plugin just returns the path of the copied file which is stored in the app cached (File loaded and cached at:/data/user/0/com.example.file_locker/cache/file_picker/Screenshot_2021-03-09-00-59-58-834_com.linkedin.android.jpg ).

I'm using file_picker: ^2.1.6.

file_picker repository issue here.

Now, are there any solutions to get the absolute path from file_picker so that I can read/write the file? I'm stuck on my project, and your solutions will be appreciated.

I've seen other file explorer plugin they also did the same way if you know some other else which return the desired solutions please let me know.

Thank you in advance.

like image 921
Nayeem Islam Avatar asked Nov 05 '25 08:11

Nayeem Islam


1 Answers

I have also faced this issue, file_picker doesn't show actual path for android, so i'm found solution for this case: "pick file and showing actual path". i'using this filesystem_picker for open file by Directory

         // for android Directory 
         Directory appDocDir = await Directory("storage/emulated/0");

         var result = await FilesystemPicker.open(allowedExtensions: [".png", ".jpg"],
         context: context,rootDirectory: appDocDir);
         if (result != null) {
             File file = File(result);
             print(file.parent.path)// the path where the file is saved 
         }
like image 129
mamena tech Avatar answered Nov 07 '25 09:11

mamena tech



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!