flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

Allow updating location stream settings

Open orkun1675 opened this issue 7 months ago • 4 comments

This PR allows updating the location stream after one is started. It adds a new API endpoint:

  /// Updates the parameters of the active position stream.
  ///
  /// Throws a [NotSubscribedException] when there is no active position stream
  /// to update.
  static Future<void> updatePositionStream({
    required LocationSettings locationSettings,
  }) =>
      GeolocatorPlatform.instance.updatePositionStream(
        locationSettings: locationSettings,
      );

This endpoint allows plugin users to change settings, such as distanceFilter or intervalDuration, without having to stop & start the stream. This is critical if the update is hapenning while the app is in the background since Android does not allow starting a location stream unless the app is in focus.

Fixes https://github.com/Baseflow/flutter-geolocator/issues/1569. Improved version of https://github.com/Baseflow/flutter-geolocator/pull/1406.

If there is interest in merging this PR I will clean it up and send for review.


Pre-launch Checklist

  • [ ] I made sure the project builds.
  • [ ] I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • [ ] I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is does not need version changes.
  • [ ] I updated CHANGELOG.md to add a description of the change.
  • [ ] I updated/added relevant documentation (doc comments with ///).
  • [ ] I rebased onto main.
  • [ ] I added new tests to check the change I am making, or this PR does not need tests.
  • [ ] I made sure all existing and new tests are passing.
  • [ ] I ran dart format . and committed any changes.
  • [ ] I ran flutter analyze and fixed any errors.

orkun1675 avatar Mar 21 '25 00:03 orkun1675