Ajith
Ajith

Reputation: 393

How to copy/download a temperory cached files to download folder in Flutter

In my flutter application (android), successfully displayed PDF file using flutter_pdfview. I am trying to copy/download the file displayed to download folder.

 Directory dir = await getApplicationDocumentsDirectory();
 string path = dir.path;
 File file = File(filePath);

 // copy file
 await file.copy('$path/$filename');

But I cant find any files locally. Any help is appreciated. Thank you.

Upvotes: 0

Views: 2126

Answers (1)

Harshvardhan Joshi
Harshvardhan Joshi

Reputation: 3193

Path provider allows access to external storage directory as well.

For the android you can use getExternalStorageDirectory() method to access the Top-level storage directory.

Make sure that the Directory, returned by this method, has a path value which says something like emulated or 0, something else which shows that it is the phone's storage directory, as storage path.

Then append /Downloads to the Directory path to read/write files from/to the Download folder.

However, this will not work for iOS.

Upvotes: 1

Related Questions