singleLocationUpdate method

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

Requests a single Location update. 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.

If no location is retrieved after some time (30 seconds on Android, ~10 seconds on iOS), the request will timeout and complete. On timeout, the device will return a less accurate location if available, or GeolocationResultErrorType.locationNotFound.

See also:


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