requestLocationPermission method

Future<GeolocationResult> requestLocationPermission (
  1. {LocationPermission permission: const LocationPermission(),
  2. bool openSettingsIfDenied: true}

Requests the location permission, if needed.

If location permission is already granted, it returns successfully. If location is not operational (location disabled, google play services unavailable on Android, etc), the request will fail without asking the permission.

If the user denied the permission before, requesting it again won't show the dialog again on iOS. On Android, it happens when user declines and checks don't ask again. In this situation, openSettingsIfDenied will show the system settings where the user can manually enable location for the app.

You don't need to call this method manually before requesting a location. Every Geolocation location request will also request the permission automatically if needed.

This method is useful to request the permission earlier in the application flow, like during an on boarding.

Requested permission must be declared in Info.plist for iOS and AndroidManifest.xml for Android. Throws a GeolocationException if the associated declaration is missing.

See also:


static Future<GeolocationResult> requestLocationPermission({
  LocationPermission permission = const LocationPermission(),
  bool openSettingsIfDenied = true,
}) =>
      openSettingsIfDenied: openSettingsIfDenied,