ivehement / saf

Flutter plugin that leverages Storage Access Framework (SAF) API to get access and perform the operations on files and folders.
https://pub.dev/packages/saf
MIT License
17 stars 19 forks source link

i don't get the logic? #11

Open nohkumado opened 2 years ago

nohkumado commented 2 years ago

i looked at your example, but its too complicated for me: i want to open Downloads to fetch a file i deposited there, i tryed:

....
if(defaultTargetPlatform == TargetPlatform.android)
                      {
                        print("target is android....");
                        Permission.storage.request();
                        print("requested stoargae access....");
                        Saf saf = Saf("/sdcard/Download");
                        print("asf started ....");
                        bool? isGranted = await saf.getDirectoryPermission(isDynamic: true); //what is the difference between dynamic and not?
                        print("asf asked permissions ....");

                        if (isGranted != null && isGranted) {
                          // Perform some file operations
                          print("asf asked directroeispath ....");
                          List<String>? directoriesPath = await Saf.getPersistedPermissionDirectories();
                          print("persistendirectories $directoriesPath");
                          List<String>? paths = await saf.getFilesPath();
                          print("paths $directoriesPath");

                        } else {
                          print("failed to get permission");
                        }
                        print("fdone for now");
}

but this opens a file browser whish is allready nice, but there i can't select the file in downloads.... so i let it create a directory at the root for it.... next try, i select the file, afterwards it asks me (again, why doesn't i reminds that i allready asked for it?) for the permission and then gets back with failed to get permission??

so i am confused, i need just the steps: check if i can access the files, if not ask for permission open the filebrowser, be able to select a file, get the filepath after selecting

how do i achieve this? and yes, android (for linux it is soooo much easier) is driving me nuts, how do i set the initial path to the correct directory? and how do i create the directory if it doesn't exist? as far as i understood i won't only get an access to a memory copy of the file? how am i supposed to write the data back?

thanks in advance

life-is-good-ok commented 5 months ago

@jvoltci @nohkumado @AMuellerAtAHS @jibexlabs Anybody knows use case of isDynamic variable?