update permission flow

This commit is contained in:
Mohamed Nouffer
2023-07-20 13:42:34 +05:30
parent ed892b915b
commit 68bf3e9ab3
2 changed files with 38 additions and 3 deletions

View File

@ -112,8 +112,9 @@ class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
requestPermission() async {
PermissionStatus permission = await Permission.location.status;
if (permission != PermissionStatus.granted) {
if(permission == PermissionStatus.permanentlyDenied){
showPermanentAlert(context);
}else{
PermissionStatus newPermission = await Permission.location.request();
//showAlert(context);
@ -125,6 +126,10 @@ class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
Get.toNamed(AppPages.TRAVEL);
}
}
// if (permission != PermissionStatus.granted) {
// }
// If permission is granted or already was granted
return true;
}
@ -138,6 +143,9 @@ class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
showAlert(context);
//requestPermission() ? Get.toNamed(AppPages.TRAVEL) : exit(0);
//Future.delayed(Duration.zero, () => showAlert(context));
}
else if(value.isPermanentlyDenied){
}
else {
Get.toNamed(AppPages.TRAVEL);
@ -150,6 +158,33 @@ class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
);
}
void showPermanentAlert(BuildContext context) {
showDialog(
context: context,
builder: (_) => AlertDialog(
title: const Text('無効'),
content: SingleChildScrollView(
child: ListBody(
children: const <Widget>[
Text( '位置情報が無効になっています'),
Text('このアプリケーションへの位置情報アクセスが無効になっています。続行するには設定>プライバシーとセキュリティ>位置情報サービス>岐阜ナビ で有効にしてください。'),
],
),
),
actions: <Widget>[
ElevatedButton(
child: const Text('OK'),
onPressed: () {
//requestPermission();
permissionServiceCall();
},
),
],
)
);
}
void showAlert(BuildContext context) {
showDialog(
context: context,