Bensal
Bensal

Reputation: 4110

Flutter: How to create a folder at the root of the directory, i.e, not under any directory

I am developing a file based application through flutter.

I can create a folder through getApplicationDocumentsDirectory() which gives the path to write files. But it cannot be seen in the files Explorer

I then created the folder through getExternalStorageDirectory() , which can be seen in the files explorer. But I want it to be created in the root.

You may have seen whatsapp folder in the root directory. I also want the same thing. I have tried the following:

Directory('FolderName').create()

But it gives the error saying 'read only os '

Is there a way to do it through flutter ?

Upvotes: 1

Views: 3534

Answers (1)

Martin Mbae
Martin Mbae

Reputation: 1266

You can do it this way:

String folderName = "My New Downloads";
var path = "storage/emulated/0/$folderName";
await  new Directory(path).create();

Upvotes: 6

Related Questions