Eng
Eng

Reputation: 1724

Flutter create file in download folder

In my app I need to download some bills. On IOS my users can easily find them when app is closed because it is stored in a dedicated folder easily findable. I achieve that with getApplicationDocumentsDirectory() from path_provider and the following option in plist :

<key>UISupportsDocumentBrowser</key>
<true/>

In android, downloaded files aren't put inside the download folder but inside the app data folder which is hard for a simple user to understand how to go in. What can I do to put bills (pdf) inside the Android Download folder ? I use for the moment the method getExternalStorageDirectory() from path_provider for Android.

Upvotes: 2

Views: 3535

Answers (1)

Eng
Eng

Reputation: 1724

Based on @blackapps responses, I used the following hard coded path in Android and fallback to getExternalStorageDirectory() if folder didn't exist.

final Directory directory = Directory('/storage/emulated/0/Download');
if (!await directory.exists()) directory = await getExternalStorageDirectory();

Upvotes: 4

Related Questions