locationUpdates method

Stream<LocationResult> locationUpdates (
  1. {@required LocationAccuracy accuracy,
  2. double displacementFilter: 0.0,
  3. bool inBackground: false,
  4. LocationPermission permission: const LocationPermission(),
  5. LocationOptionsAndroid androidOptions: LocationOptionsAndroid.defaultContinuous,
  6. LocationOptionsIOS iosOptions: const LocationOptionsIOS()}
)

Requests continuous Location updates. 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.

Filter minimum displacementFilter distance in meters between each Location updates.

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.

LocationResult will be pushed down the stream continuously until the subscription is cancelled. To stop the ongoing location request, cancel the subscription.

See also:

Implementation

static Stream<LocationResult> locationUpdates({
  @required LocationAccuracy accuracy,
  double displacementFilter = 0.0,
  bool inBackground = false,
  LocationPermission permission = const LocationPermission(),
  LocationOptionsAndroid androidOptions =
      LocationOptionsAndroid.defaultContinuous,
  LocationOptionsIOS iosOptions = const LocationOptionsIOS(),
}) =>
    _locationChannel.locationUpdates(_LocationUpdatesRequest(
      _LocationUpdateStrategy.continuous,
      permission,
      accuracy,
      inBackground,
      androidOptions,
      iosOptions,
      displacementFilter,
    ));