I'm trying to build a Flutter application that runs on Android 11 and downloads files. I used to manage external storage permission to achieve this, but when the application asks for permission it goes to settings directly instead of asking for allow or deny within the app.
For example, WhatsApp stores data in the android/media folder, but it asks for permission directly within the application instead of going to the settings page. Please refer the below images:
My application goes to settings like this / I need something like this
My permission handling code
Future<bool> requestPermission() async {
var androidInfo = await DeviceInfoPlugin().androidInfo;
var release = int.parse(androidInfo.version.release);
Permission permission;
if (release < 11) {
permission = Permission.storage;
} else {
permission = Permission.manageExternalStorage;
}
if (await permission.isGranted) {
return true;
} else {
var result = await permission.request();
if (result == PermissionStatus.granted) {
return true;
} else {
return false;
}
}
}