I am new in Flutter. I want to store my document file into '/storage/emulated/0/Download/'. I have error about Unhandled Exception: FileSystemException: Cannot open file, path = '/storage/emulated/0/Download/file.pdf' (OS Error: Permission denied, errno = 13)
Here is my code:
void download() async {
http.Response response = await http.post(url, headers: {"Accept": "application/json", HttpHeaders.authorizationHeader: 'Bearer}});
File file = new File('/storage/emulated/0/Download/file.pdf');
await file.writeAsBytes(response.bodyBytes);
}
In Android Q, you need to add the Following Lines in AndroidManifest file:
<application
android:requestLegacyExternalStorage="true"
Just add the following lines in to your android manifest if you're on android 10/Q
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:requestLegacyExternalStorage="true"
>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With