currentLocation method

Stream<LocationResult> currentLocation (
  1. {@required LocationAccuracy accuracy,
  2. bool inBackground: false,
  3. LocationPermission permission: const LocationPermission(),
  4. LocationOptionsAndroid androidOptions: LocationOptionsAndroid.defaultSingle,
  5. LocationOptionsIOS iosOptions: const LocationOptionsIOS()}

Requests the current "one-shot" Location, using Android and iOS best practice mechanics. Automatically request location permission beforehand if not granted.

The location service will try to match the requested accuracy, but it can also return a less accurate Location as fallback.

By default, location requests are stopped when app goes to background, and resumed when app comes back to foreground. You can disable this behaviour by setting true for inBackground.

A single LocationResult will be pushed down the stream, and the stream will complete. To stop the ongoing location request, cancel the subscription.

Behaviour per platform:

  • Android: Returns the last known location if available and valid. Otherwise requests a single location update. If last known location is retrieved, no location request is started. accuracy and inBackground will be ignored.
  • iOS: Requests a single location update.

See also:


static Stream<LocationResult> currentLocation({
  @required LocationAccuracy accuracy,
  bool inBackground = false,
  LocationPermission permission = const LocationPermission(),
  LocationOptionsAndroid androidOptions =
  LocationOptionsIOS iosOptions = const LocationOptionsIOS(),
}) =>