onRequestPermissions method

  1. @override
Future<void> onRequestPermissions()
override

Callback on requestPermissions.

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

Implementation

@override
Future<void> onRequestPermissions() async {
  if (types.isNotEmpty) {
    try {
      if (Platform.isIOS) {
        _hasPermissions = await service?.requestAuthorization(types) ?? false;
      } else if (Platform.isAndroid) {
        // on Android the requestAuthorization() method never returns - so
        // don't await it
        service?.requestAuthorization(types);
      }
    } catch (error) {
      warning('$runtimeType - Error requesting permissions - $error');
    }
  }
}