requestLocationPermission method

Future<GeolocationResult> requestLocationPermission ([LocationPermission permission = const LocationPermission() ])

Requests the location permission, if needed.

If location permission is already granted, it returns successfully. If location is not operational, the request will fail without asking the permission.

You don't need to call this method manually. Every Geolocation method requiring the location permission will request it automatically if needed. Automatic permission request always request LocationPermissionAndroid.fine and LocationPermissionIOS.whenInUse. If you want another permission request, you have to request it manually. Also it's a common practice to request the permission early in the application flow (like during an on boarding flow).

Request permission must also be declared in Info.plist for iOS and AndroidManifest.xml for Android. If required declaration is missing, location will not work. Throws a GeolocationException if missing, to help you catch this mistake.

See also:


static Future<GeolocationResult> requestLocationPermission([
  LocationPermission permission = const LocationPermission(),
]) =>