singleLocationUpdate method

Stream<LocationResult> singleLocationUpdate ({@required LocationAccuracy accuracy, bool inBackground: false, LocationPermission permission: const LocationPermission() })

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:

Implementation

static Stream<LocationResult> singleLocationUpdate({
  @required LocationAccuracy accuracy,
  bool inBackground = false,
  LocationPermission permission = const LocationPermission(),
}) =>
    _locationChannel.locationUpdates(new _LocationUpdatesRequest(
      _LocationUpdateStrategy.single,
      permission,
      accuracy,
      inBackground,
    ));