requestPermission method

  1. @override
Future<LocationPermission> requestPermission({
  1. List<String> permissions = GeolocatorOhos.approximatelyPermission,
})
override

Request permission to access the location of the device.

Returns a Future which when completes indicates if the user granted permission to access the device's location. Throws a PermissionDefinitionsNotFoundException when the required platform specific configuration is missing (e.g. in the AndroidManifest.xml on Android or the Info.plist on iOS). A PermissionRequestInProgressException is thrown if permissions are requested while an earlier request has not yet been completed.

Implementation

@override
Future<LocationPermission> requestPermission(
    {List<String> permissions =
        GeolocatorOhos.approximatelyPermission}) async {
  try {
    // ignore: omit_local_variable_types
    final int permission = await GeolocatorOhos._methodChannel
        .invokeMethod('requestPermission', permissions);

    return permission.toLocationPermission();
  } on PlatformException catch (e) {
    final error = _handlePlatformException(e);

    throw error;
  }
}