getPermissionResult static method Null safety

Future<int> getPermissionResult(
  1. Permissions permission
)

Return 1 if permission is granted, return 0 if denied, return -1 if user set to don't ask again

Implementation

static Future<int> getPermissionResult(Permissions permission) async {
  var permissionName = _getEquivalentPermissionName(permission)!;
  var permissionStatus = await permissionName.status;
  int result;
  if (permissionStatus == PermissionStatus.granted) {
    result = 1;
  } else if (permissionStatus == PermissionStatus.limited) {
    result = 1;
  } else if (permissionStatus == PermissionStatus.permanentlyDenied) {
    result = -1;
  } else {
    result = 0;
  }
  return result;
}