From 68bf3e9ab37d62cc6d28badaf096fd19356abe62 Mon Sep 17 00:00:00 2001 From: Mohamed Nouffer Date: Thu, 20 Jul 2023 13:42:34 +0530 Subject: [PATCH] update permission flow --- lib/pages/permission/permission.dart | 39 ++++++++++++++++++++++++++-- pubspec.yaml | 2 +- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/lib/pages/permission/permission.dart b/lib/pages/permission/permission.dart index 5064f08..146af32 100644 --- a/lib/pages/permission/permission.dart +++ b/lib/pages/permission/permission.dart @@ -112,8 +112,9 @@ class _PermissionHandlerScreenState extends State { 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 { 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 { 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 { ); } + void showPermanentAlert(BuildContext context) { + showDialog( + context: context, + builder: (_) => AlertDialog( + title: const Text('無効'), + content: SingleChildScrollView( + child: ListBody( + children: const [ + Text( '位置情報が無効になっています'), + Text('このアプリケーションへの位置情報アクセスが無効になっています。続行するには設定>プライバシーとセキュリティ>位置情報サービス>岐阜ナビ で有効にしてください。'), + ], + ), + ), + actions: [ + ElevatedButton( + child: const Text('OK'), + onPressed: () { + //requestPermission(); + permissionServiceCall(); + }, + ), + ], + ) + ); + } + + void showAlert(BuildContext context) { showDialog( context: context, diff --git a/pubspec.yaml b/pubspec.yaml index fc00fdd..c72f2ce 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.0.15+15 +version: 1.0.16+16 environment: sdk: ">=2.16.0 <3.0.0"