Skip to content

WatchPositionRequest

Options for BackgroundGeolocation.watchPosition.

Configures the interval, accuracy, persistence, and metadata for a continuous location stream. All fields are optional.

Warning

watchPosition is intended for foreground use. On iOS it prevents the app from being suspended, which drains the battery. Remove the subscription when your app moves to the background.

final subscription = BackgroundGeolocation.watchPosition(
  {'interval': 1000, 'desiredAccuracy': DesiredAccuracy.high},
  (Location location) {
    print('[watchPosition] ${location}');
  },
  (int errorCode) {
    print('[watchPosition] error: ${errorCode}');
  }
);

// Later, stop watching.
subscription.remove();