requestPermission method

  1. @override
Future<LocationPermission> requestPermission()

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() async {
  try {
    // ignore: omit_local_variable_types
    final int permission =
        await _methodChannel.invokeMethod('requestPermission');

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

    throw error;
  }
}