Flutter Unable to create directory (OS Error: Read-only file system)
Got it (Using path_provider plugin to get correct path)
Directory appDocDirectory = await getApplicationDocumentsDirectory();
new Directory(appDocDirectory.path+'/'+'dir').create(recursive: true)
// The created directory is returned as a Future.
.then((Directory directory) {
print('Path of New Dir: '+directory.path);
});
Update : New Flutter plugin permission_handler have taken care below thing so change your plugin to permission_handler
If you are testing in Android Oreo and want to write file in external storage then you need to ask WRITE_EXTERNAL_STORAGE
According to "https://developer.android.com/about/versions/oreo/android-8.0-changes.html#rmp"
If the app targets Android 8.0 (API level 26), the system grants only READ_EXTERNAL_STORAGE at that time; however, if the app later requests WRITE_EXTERNAL_STORAGE, the system immediately grants that privilege without prompting the user.
Permission Plugin ask only READ_EXTERNAL_STORAGE permission by Permission.requestPermissions([PermissionName.Storage])
;
so You need to ask for WRITE_EXTERNAL_STORAGE.
You can use my repo for asking WRITE_EXTERNAL_STORAGE in pubspec.yaml:
permission:
git:
url: https://github.com/kamlesh9070/permission