My Flutter app needs to read from and write to the Download folder (/storage/emulated/0/Download, more precisely).
Prior to targeting the SDK version 29 (targetSdkVersion 29 in build.gradle), this went well, only by requesting
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:remove="android:maxSdkVersion" />
in AndroidManifest.xml.
To my surprise, after deploying a new version to my phone, the app started to raise access denied errors when trying to access that folder, despite having granted access for the two permissions mentioned above. I suppose this was because I changed the targetSDKVersion to 29.
The solution was to add android:requestLegacyExternalStorage="true" to the <app> node in AndroidManifest.xml.
However, it seems that Android 11 will ignore this flag, so it is only a temporary fix.
So, my question is: what is the right, official, robust way to ensure access to the Download folder for a Flutter app, in the upcoming Android version?
Usage of the Download folder is a strict requirement.
Thank you!