'i try to make permission handler for flutter
I am building a music player application. I want to ask the user to allow access to storage when the application is opened. I used this method and it works properly during testing, but when I get output from the application and upload it to the Google Store, it does not allow access.
Where is my problem?
denied() {
return showDialog(
barrierColor: Colors.white.withOpacity(0.5),
context: context,
builder: (context) {
return AlertDialog(
backgroundColor: Colors.black,
title: Text(
'Allow Permission',
style: TextStyle(color: Colors.white),
),
content: Container(
height: MediaQuery.of(context).size.height * 0.2,
child: Column(
children: [
Text(
'Music Player needs access to audio files to play music.',
style: TextStyle(color: Colors.white),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TextButton(
onPressed: () {
_promasionrequest();
Navigator.pop(context);
},
child: Text(
'Allow',
style: TextStyle(
fontWeight: FontWeight.normal,
fontStyle: FontStyle.italic,
color: Colors.blue),
)),
TextButton(
onPressed: () {
exit(0);
},
child: Text(
'Deny',
style: TextStyle(
fontWeight: FontWeight.normal,
fontStyle: FontStyle.italic,
color: Colors.blue),
))
],
)
],
),
));
});
}
_promasionrequest() async {
Permission.storage.request();
var status = await Permission.storage.status;
setState(() {
permissionStatus = status;
});
setState(() {
switch (status) {
case PermissionStatus.granted:
setState(() {
acsept = true;
});
getSongs();
break;
case PermissionStatus.denied:
denied();
testText = 'denied';
break;
case PermissionStatus.limited:
denied();
testText = 'limited';
break;
case PermissionStatus.restricted:
denied();
testText = 'restricted';
break;
case PermissionStatus.permanentlyDenied:
denied();
testText = 'permanentlyDenied';
break;
default:
// getSongs();
}
});
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
