getPositionStream method

Stream<Position> getPositionStream({
  1. LocationSettings? locationSettings,
})

Fires whenever the location changes inside the bounds of the desiredAccuracy.

This event starts all location sensors on the device and will keep them active until you cancel listening to the stream or when the application is killed.

StreamSubscription<Position> positionStream = getPositionStream()
    .listen((Position position) {
      // Handle position changes
    });

// When no longer needed cancel the subscription
positionStream.cancel();

You can control the precision of the location updates by supplying the desiredAccuracy parameter (defaults to "best"). The distanceFilter parameter controls the minimum distance the device needs to move before the update is emitted (default value is 0 indicator no filter is used). On Android you can force the use of the Android LocationManager instead of the FusedLocationProvider by setting the forceLocationManager parameter of LocationSettings to true. Using the timeInterval of LocationSettings you can control the amount of time that needs to pass before the next position update is send.

Throws a PermissionDeniedException when trying to request the device's location when the user denied access. Throws a LocationServiceDisabledException when the user allowed access, but the location services of the device are disabled.

Implementation

Stream<Position> getPositionStream({
  LocationSettings? locationSettings,
}) {
  throw UnimplementedError('getPositionStream() has not been implemented.');
}