Reputation: 3473
I am using the below method to detect users had allowed location permission all the time or not. Is it possible to detect whether the user can selected the option for "Allow while using app" option in android?
import 'package:permission_handler/permission_handler.dart'; It consists of status values :
/// Returns a list of all possible [PermissionStatus] values.
static const List<PermissionStatus> values = <PermissionStatus>[
denied,
granted,
restricted, - But this only works for iOS and not for Android.
unknown,
neverAskAgain,
];
Is there another plugin which works for both Android and iOS and I can get the status of user action for location popup?
These are 4 option in location popup in Android Deny Never ask again Allow only while using app Always allow.
I wanted to detect when user click any of this states?
Upvotes: 1
Views: 430
Reputation: 2355
you should use permanentlyDenied
for android version
you can do this
import 'dart:io' show Platform;
static const List<PermissionStatus> values;
if (Platform.isAndroid) {
values = <PermissionStatus>[
denied,
granted,
permanentlyDenied,
unknown,
neverAskAgain,
];
} else if (Platform.isIOS) {
values = <PermissionStatus>[
denied,
granted,
restricted,
unknown,
neverAskAgain,
];
}
Upvotes: 1