onHasPermissions method

  1. @override
Future<bool> onHasPermissions()
override

Callback on hasPermissions.

Can be overridden in sub-classes for device-specific permission handling.

Implementation

@override
Future<bool> onHasPermissions() async {
  if (!_hasPermissions) {
    if (types.isNotEmpty) {
      try {
        if (Platform.isIOS) {
          // the only way to know if permissions is granted on iOS is via the
          // requestAuthorization() method (see issue above)
          _hasPermissions =
              await service?.requestAuthorization(types) ?? false;
        } else if (Platform.isAndroid) {
          _hasPermissions = await service?.hasPermissions(types) ?? false;
        }
      } catch (error) {
        warning('$runtimeType - Error getting permission status - $error');
      }
    } else {
      _hasPermissions = true;
    }
  }
  return _hasPermissions;
}