updated permission
This commit is contained in:
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:rogapp/routes/app_pages.dart';
|
||||
import 'dart:io';
|
||||
|
||||
class PermissionHandlerScreen extends StatefulWidget {
|
||||
PermissionHandlerScreen({Key? key}) : super(key: key);
|
||||
@ -87,18 +88,17 @@ class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
|
||||
].request();
|
||||
|
||||
if (statuses[Permission.location]!.isPermanentlyDenied) {
|
||||
_showMyDialog();
|
||||
// await openAppSettings().then(
|
||||
// (value) async {
|
||||
// if (value) {
|
||||
// if (await Permission.location.status.isPermanentlyDenied == true &&
|
||||
// await Permission.location.status.isGranted == false) {
|
||||
// // openAppSettings();
|
||||
// permissionServiceCall(); /* opens app settings until permission is granted */
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// );
|
||||
await openAppSettings().then(
|
||||
(value) async {
|
||||
if (value) {
|
||||
if (await Permission.location.status.isPermanentlyDenied == true &&
|
||||
await Permission.location.status.isGranted == false) {
|
||||
// openAppSettings();
|
||||
permissionServiceCall(); /* opens app settings until permission is granted */
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
} else {
|
||||
if (statuses[Permission.location]!.isDenied) {
|
||||
permissionServiceCall();
|
||||
@ -110,12 +110,34 @@ class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
|
||||
}
|
||||
|
||||
|
||||
requestPermission() async {
|
||||
PermissionStatus permission = await Permission.location.status;
|
||||
|
||||
if (permission != PermissionStatus.granted) {
|
||||
PermissionStatus newPermission = await Permission.location.request();
|
||||
//showAlert(context);
|
||||
|
||||
if (newPermission != PermissionStatus.granted) {
|
||||
// If permission not granted, handle the issue in your own way
|
||||
exit(0);
|
||||
}
|
||||
else{
|
||||
Get.toNamed(AppPages.TRAVEL);
|
||||
}
|
||||
}
|
||||
// If permission is granted or already was granted
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var status = Permission.location.status.then((value){
|
||||
if(value.isGranted == false){
|
||||
Future.delayed(Duration.zero, () => showAlert(context));
|
||||
showAlert(context);
|
||||
//requestPermission() ? Get.toNamed(AppPages.TRAVEL) : exit(0);
|
||||
//Future.delayed(Duration.zero, () => showAlert(context));
|
||||
}
|
||||
else {
|
||||
Get.toNamed(AppPages.TRAVEL);
|
||||
@ -145,7 +167,8 @@ class _PermissionHandlerScreenState extends State<PermissionHandlerScreen> {
|
||||
TextButton(
|
||||
child: const Text('わかった'),
|
||||
onPressed: () {
|
||||
permissionServiceCall();
|
||||
requestPermission();
|
||||
//permissionServiceCall();
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user