Flutter Unable to create directory (OS Error: Read-only file system)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Flutter Unable to create directory (OS Error: Read-only file system)



I was following - how to create directory from https://docs.flutter.io/flutter/dart-io/Directory-class.html


new Directory('dir/subdir').create(recursive: true)
// The created directory is returned as a Future.
.then((Directory directory) {
print(directory.path);
});



This is the error I am getting:



FileSystemException: Creation failed, path = 'dir' (OS Error: Read-only file system, errno = 30)



I have enabled Storage(WRITE_EXTERNAL_STORAGE) permission.
(Android device)


Storage(WRITE_EXTERNAL_STORAGE)



What am I missing?





Use pub.dartlang.org/packages/path_provider to get valid paths where you can read/write files.
– Günter Zöchbauer
47 mins ago





@GünterZöchbauer thanks. Flutter Docs are slightly confusing.
– UpaJah
12 mins ago




1 Answer
1



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);
});






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Visual Studio Code: How to configure includePath for better IntelliSense results

Spring cloud config client Could not locate PropertySource

Makefile test if variable is not empty