Project 'testapp-system/file_picker_cross' was moved to 'TheOneWithTheBraid/file_picker_cross'. Please update any links and bookmarks that may still have the old path.
Was looking for the possibility of picking a directory, as I don't see support for that on file_picker. Is that something that could be done with this plugin?
Designs
Child items 0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items 0
Link issues together to show that they're related.
Learn more.
Thank you @leoafarias . This is a great idea. I just didn't think about it before.
I will check out if I can add support for directory choosing in the next version but I have concerns that this might be difficult for the web platform as web pages only have very limited access to computer's file systems. Maybe the JavaScript FileSystem-API might help to integrate this?
As with version 4.0.0, this should now be possible using the fake file system.
If you can tell me what exactly you want to do with the directory, I might help you. The issue with picking a directory is, that Android and iOS apps are isolated and actually not able to directly access files and directories on your storage.
@TheOneWithTheBraid Well, a Simple use-case would be saving files into a directory. I am working on a desktop app that allows us to export data in CSV form. I want user to select a directory in which I could save the file.
I see. Would the FilePickerCross().saveToPath('/mypath') introduced in version 4.1.0 help?
Since that version, we introduced a local read-write file system for storing FilePickerCross on the local disk without issuing around with storage permissions etc. Read our scope for a more detailed impression and have a look at our example code to get an idea how it works.
It does not show a file chooser or directory picker but creates saves the file accessible for later use inside the app's data directory (%APPDATA%\your_apps_name\ on Windows $(xdg-user-dir)/.your_apps_name on Linux).
If you really, really need to export to user-defined directories, another way to get a user-defined directory (on Desktops only) would be showing a export dialog and using the selected directory for future exports:
FilePickerCrossmyFile=...StringpathForExports=awaitmyFile.exportToStorage();// <- will return the file's pathpathForExports=pathForExports.substring(0,pathForExports.lastIndexOf(r'/'));print(pathForExports);// now save the path for later use using shared preferences etc.FilemyCsvFile=awaitFile(pathForExports+'/myNextFile.csv').writeAsString('comma,seperated,values').
The problem with a full read and write directory chooser is security. First of all, it is not possible to implement this on iOS, nor it is currently for the web. For Android it is possible if you workaround several security mechanisms. On desktops, there is currently no platform implementation available.
@TheOneWithTheBraid I didn't know about await myFile.exportToStorage();. I need to export to user-defined directories. So as I understand this, It should work. I'll give it a try. Thanks for the help.