askPermission static method
Asks(request) for permission and return true if granted, otherwise returns false. If the permission is permanently denied, This will open the settings
Implementation
static Future<bool> askPermission(Permissions permission) async {
int result = await getPermissionResult(permission);
var permissionName = _getEquivalentPermissionName(permission);
if (result == 0) {
// Code for deny (false)
var status = await permissionName!.request();
return status == PermissionStatus.granted ||
status == PermissionStatus.limited;
} else if (result == -1) {
// Code for notAgain (false)
await openAppSettings();
result = await getPermissionResult(permission);
return result == 1;
} else {
// already granted
return true;
}
}