From c855ddb0eacc3915c052b0f1c651c111920ad601 Mon Sep 17 00:00:00 2001 From: Orkun Duman Date: Mon, 9 Dec 2024 00:30:02 -0500 Subject: [PATCH 1/4] [Android and iOS] Throw LocationSignalLostException when GPS signal is lost --- .../java/com/baseflow/geolocator/errors/ErrorCodes.java | 5 +++++ .../geolocator/location/FusedLocationClient.java | 4 ++-- .../android/gradle/wrapper/gradle-wrapper.properties | 5 +++-- geolocator_android/lib/src/geolocator_android.dart | 2 ++ geolocator_android/pubspec.yaml | 3 ++- geolocator_apple/ios/Classes/Constants/ErrorCodes.h | 1 + geolocator_apple/ios/Classes/Constants/ErrorCodes.m | 1 + .../ios/Classes/Handlers/GeolocationHandler.m | 3 +++ geolocator_apple/lib/src/geolocator_apple.dart | 2 ++ geolocator_apple/pubspec.yaml | 3 ++- geolocator_platform_interface/lib/src/errors/errors.dart | 1 + .../lib/src/errors/location_signal_lost_exception.dart | 9 +++++++++ .../src/implementations/method_channel_geolocator.dart | 2 ++ 13 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 geolocator_platform_interface/lib/src/errors/location_signal_lost_exception.dart diff --git a/geolocator_android/android/src/main/java/com/baseflow/geolocator/errors/ErrorCodes.java b/geolocator_android/android/src/main/java/com/baseflow/geolocator/errors/ErrorCodes.java index cea4141e1..03564f795 100644 --- a/geolocator_android/android/src/main/java/com/baseflow/geolocator/errors/ErrorCodes.java +++ b/geolocator_android/android/src/main/java/com/baseflow/geolocator/errors/ErrorCodes.java @@ -4,6 +4,7 @@ public enum ErrorCodes { activityMissing, errorWhileAcquiringPosition, locationServicesDisabled, + locationSignalLost, permissionDefinitionsNotFound, permissionDenied, permissionRequestInProgress; @@ -16,6 +17,8 @@ public String toString() { return "ERROR_WHILE_ACQUIRING_POSITION"; case locationServicesDisabled: return "LOCATION_SERVICES_DISABLED"; + case locationSignalLost: + return "LOCATION_SIGNAL_LOST"; case permissionDefinitionsNotFound: return "PERMISSION_DEFINITIONS_NOT_FOUND"; case permissionDenied: @@ -35,6 +38,8 @@ public String toDescription() { return "An unexpected error occurred while trying to acquire the device's position."; case locationServicesDisabled: return "Location services are disabled. To receive location updates the location services should be enabled."; + case locationSignalLost: + return "Location signal has been lost. Further location updates are unlikely until something changes with the device's settings or environment."; case permissionDefinitionsNotFound: return "No location permissions are defined in the manifest. Make sure at least ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION are defined in the manifest."; case permissionDenied: diff --git a/geolocator_android/android/src/main/java/com/baseflow/geolocator/location/FusedLocationClient.java b/geolocator_android/android/src/main/java/com/baseflow/geolocator/location/FusedLocationClient.java index a5e3f2b13..3259df3b3 100644 --- a/geolocator_android/android/src/main/java/com/baseflow/geolocator/location/FusedLocationClient.java +++ b/geolocator_android/android/src/main/java/com/baseflow/geolocator/location/FusedLocationClient.java @@ -85,9 +85,9 @@ public synchronized void onLocationResult(@NonNull LocationResult locationResult @Override public synchronized void onLocationAvailability( @NonNull LocationAvailability locationAvailability) { - if (!locationAvailability.isLocationAvailable() && !checkLocationService(context)) { + if (!locationAvailability.isLocationAvailable()) { if (errorCallback != null) { - errorCallback.onError(ErrorCodes.locationServicesDisabled); + errorCallback.onError(checkLocationService(context) ? ErrorCodes.locationSignalLost : ErrorCodes.locationServicesDisabled); } } } diff --git a/geolocator_android/example/android/gradle/wrapper/gradle-wrapper.properties b/geolocator_android/example/android/gradle/wrapper/gradle-wrapper.properties index b4ab7d88e..1af9e0930 100644 --- a/geolocator_android/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/geolocator_android/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ -#Wed Aug 12 09:15:23 CEST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip diff --git a/geolocator_android/lib/src/geolocator_android.dart b/geolocator_android/lib/src/geolocator_android.dart index 04c1ced86..918ef5677 100644 --- a/geolocator_android/lib/src/geolocator_android.dart +++ b/geolocator_android/lib/src/geolocator_android.dart @@ -245,6 +245,8 @@ class GeolocatorAndroid extends GeolocatorPlatform { return ActivityMissingException(exception.message); case 'LOCATION_SERVICES_DISABLED': return const LocationServiceDisabledException(); + case 'LOCATION_SIGNAL_LOST': + return const LocationSignalLostException(); case 'LOCATION_SUBSCRIPTION_ACTIVE': return const AlreadySubscribedException(); case 'PERMISSION_DEFINITIONS_NOT_FOUND': diff --git a/geolocator_android/pubspec.yaml b/geolocator_android/pubspec.yaml index 8841c1169..99f9cbcb9 100644 --- a/geolocator_android/pubspec.yaml +++ b/geolocator_android/pubspec.yaml @@ -20,7 +20,8 @@ flutter: dependencies: flutter: sdk: flutter - geolocator_platform_interface: ^4.1.0 + geolocator_platform_interface: + path: ../geolocator_platform_interface meta: ^1.10.0 uuid: ">=4.0.0 <6.0.0" diff --git a/geolocator_apple/ios/Classes/Constants/ErrorCodes.h b/geolocator_apple/ios/Classes/Constants/ErrorCodes.h index fa87ca149..e02f52a17 100644 --- a/geolocator_apple/ios/Classes/Constants/ErrorCodes.h +++ b/geolocator_apple/ios/Classes/Constants/ErrorCodes.h @@ -8,6 +8,7 @@ FOUNDATION_EXPORT NSString * const GeolocatorErrorLocationUpdateFailure; FOUNDATION_EXPORT NSString * const GeolocatorErrorLocationServicesDisabled; FOUNDATION_EXPORT NSString * const GeolocatorErrorLocationSubscriptionActive; +FOUNDATION_EXPORT NSString * const GeolocatorErrorLocationSignalLost; FOUNDATION_EXPORT NSString * const GeolocatorErrorPermissionDefinitionsNotFound; FOUNDATION_EXPORT NSString * const GeolocatorErrorPermissionDenied; FOUNDATION_EXPORT NSString * const GeolocatorErrorPermissionRequestInProgress; diff --git a/geolocator_apple/ios/Classes/Constants/ErrorCodes.m b/geolocator_apple/ios/Classes/Constants/ErrorCodes.m index b1ffe7a01..378554116 100644 --- a/geolocator_apple/ios/Classes/Constants/ErrorCodes.m +++ b/geolocator_apple/ios/Classes/Constants/ErrorCodes.m @@ -10,6 +10,7 @@ NSString * const GeolocatorErrorLocationUpdateFailure = @"LOCATION_UPDATE_FAILURE"; NSString * const GeolocatorErrorLocationServicesDisabled = @"LOCATION_SERVICES_DISABLED"; NSString * const GeolocatorErrorLocationSubscriptionActive = @"LOCATION_SUBSCRIPTION_ACTIVE"; +NSString * const GeolocatorErrorLocationSignalLost = @"LOCATION_SIGNAL_LOST"; NSString * const GeolocatorErrorPermissionDefinitionsNotFound = @"PERMISSION_DEFINITIONS_NOT_FOUND"; NSString * const GeolocatorErrorPermissionDenied = @"PERMISSION_DENIED"; NSString * const GeolocatorErrorPermissionRequestInProgress = @"PERMISSION_REQUEST_IN_PROGRESS"; diff --git a/geolocator_apple/ios/Classes/Handlers/GeolocationHandler.m b/geolocator_apple/ios/Classes/Handlers/GeolocationHandler.m index e3808f185..1d9f79990 100644 --- a/geolocator_apple/ios/Classes/Handlers/GeolocationHandler.m +++ b/geolocator_apple/ios/Classes/Handlers/GeolocationHandler.m @@ -187,6 +187,9 @@ - (void)locationManager:(CLLocationManager *)manager "Error description: %@", error.localizedFailureReason, error.localizedDescription); if([error.domain isEqualToString:kCLErrorDomain] && error.code == kCLErrorLocationUnknown) { + if (self.errorHandler) { + self.errorHandler(GeolocatorErrorLocationSignalLost, error.localizedDescription); + } return; } diff --git a/geolocator_apple/lib/src/geolocator_apple.dart b/geolocator_apple/lib/src/geolocator_apple.dart index 8475bdd2d..eb3ca1ab9 100644 --- a/geolocator_apple/lib/src/geolocator_apple.dart +++ b/geolocator_apple/lib/src/geolocator_apple.dart @@ -234,6 +234,8 @@ class GeolocatorApple extends GeolocatorPlatform { return const LocationServiceDisabledException(); case 'LOCATION_SUBSCRIPTION_ACTIVE': return const AlreadySubscribedException(); + case 'LOCATION_SIGNAL_LOST': + return const LocationSignalLostException(); case 'PERMISSION_DEFINITIONS_NOT_FOUND': return PermissionDefinitionsNotFoundException(exception.message); case 'PERMISSION_DENIED': diff --git a/geolocator_apple/pubspec.yaml b/geolocator_apple/pubspec.yaml index 270b13a3e..7487227ee 100644 --- a/geolocator_apple/pubspec.yaml +++ b/geolocator_apple/pubspec.yaml @@ -22,7 +22,8 @@ flutter: dependencies: flutter: sdk: flutter - geolocator_platform_interface: ^4.1.0 + geolocator_platform_interface: + path: ../geolocator_platform_interface dev_dependencies: async: ^2.8.2 diff --git a/geolocator_platform_interface/lib/src/errors/errors.dart b/geolocator_platform_interface/lib/src/errors/errors.dart index 3bbfcfe57..3dde4876d 100644 --- a/geolocator_platform_interface/lib/src/errors/errors.dart +++ b/geolocator_platform_interface/lib/src/errors/errors.dart @@ -2,6 +2,7 @@ export 'activity_missing_exception.dart'; export 'already_subscribed_exception.dart'; export 'invalid_permission_exception.dart'; export 'location_service_disabled_exception.dart'; +export 'location_signal_lost_exception.dart'; export 'permission_definitions_not_found_exception.dart'; export 'permission_denied_exception.dart'; export 'permission_request_in_progress_exception.dart'; diff --git a/geolocator_platform_interface/lib/src/errors/location_signal_lost_exception.dart b/geolocator_platform_interface/lib/src/errors/location_signal_lost_exception.dart new file mode 100644 index 000000000..6d752e34f --- /dev/null +++ b/geolocator_platform_interface/lib/src/errors/location_signal_lost_exception.dart @@ -0,0 +1,9 @@ +/// An exception thrown when the GPS signal is lost. +class LocationSignalLostException implements Exception { + /// Constructs the [LocationSignalLostException] + const LocationSignalLostException(); + + @override + String toString() => 'The location service on the device is unable to ' + 'retrieve a location. Possibly because the GPS signal is lost.'; +} diff --git a/geolocator_platform_interface/lib/src/implementations/method_channel_geolocator.dart b/geolocator_platform_interface/lib/src/implementations/method_channel_geolocator.dart index fefc185e8..252c91a8b 100644 --- a/geolocator_platform_interface/lib/src/implementations/method_channel_geolocator.dart +++ b/geolocator_platform_interface/lib/src/implementations/method_channel_geolocator.dart @@ -232,6 +232,8 @@ class MethodChannelGeolocator extends GeolocatorPlatform { return ActivityMissingException(exception.message); case 'LOCATION_SERVICES_DISABLED': return const LocationServiceDisabledException(); + case 'LOCATION_SIGNAL_LOST': + return const LocationSignalLostException(); case 'LOCATION_SUBSCRIPTION_ACTIVE': return const AlreadySubscribedException(); case 'PERMISSION_DEFINITIONS_NOT_FOUND': From 93133673c631bc599160fa0be50245cd228408b5 Mon Sep 17 00:00:00 2001 From: Orkun Duman Date: Mon, 9 Dec 2024 00:40:38 -0500 Subject: [PATCH 2/4] Add unit tests and fix versioning --- geolocator_android/pubspec.yaml | 3 +- .../test/geolocator_android_test.dart | 35 +++++++++++++++++++ geolocator_apple/pubspec.yaml | 3 +- .../test/geolocator_apple_test.dart | 35 +++++++++++++++++++ geolocator_platform_interface/pubspec.yaml | 2 +- .../method_channel_geolocator_test.dart | 33 +++++++++++++++++ 6 files changed, 106 insertions(+), 5 deletions(-) diff --git a/geolocator_android/pubspec.yaml b/geolocator_android/pubspec.yaml index 99f9cbcb9..0ab9bacdb 100644 --- a/geolocator_android/pubspec.yaml +++ b/geolocator_android/pubspec.yaml @@ -20,8 +20,7 @@ flutter: dependencies: flutter: sdk: flutter - geolocator_platform_interface: - path: ../geolocator_platform_interface + geolocator_platform_interface: ^4.3.0 meta: ^1.10.0 uuid: ">=4.0.0 <6.0.0" diff --git a/geolocator_android/test/geolocator_android_test.dart b/geolocator_android/test/geolocator_android_test.dart index 6611a6ba9..0350fb013 100644 --- a/geolocator_android/test/geolocator_android_test.dart +++ b/geolocator_android/test/geolocator_android_test.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:geolocator_android/geolocator_android.dart'; +import 'package:geolocator_platform_interface/geolocator_platform_interface.dart'; import 'event_channel_mock.dart'; import 'method_channel_mock.dart'; @@ -1071,6 +1072,40 @@ void main() { streamController.close(); }); + test( + // ignore: lines_longer_than_80_chars + 'Should receive a location signal lost exception if location signal is lost', + () async { + // Arrange + final streamController = + StreamController.broadcast(); + EventChannelMock( + channelName: 'flutter.baseflow.com/geolocator_updates_android', + stream: streamController.stream, + ); + + // Act + final positionStream = GeolocatorAndroid().getPositionStream(); + final streamQueue = StreamQueue(positionStream); + + // Emit test error + streamController.addError(PlatformException( + code: 'LOCATION_SIGNAL_LOST', + message: 'Location signal lost', + details: null)); + + // Assert + expect( + streamQueue.next, + throwsA( + isA(), + )); + + // Clean up + streamQueue.cancel(); + streamController.close(); + }); + test( // ignore: lines_longer_than_80_chars 'Should receive a already subscribed exception', () async { diff --git a/geolocator_apple/pubspec.yaml b/geolocator_apple/pubspec.yaml index 7487227ee..cc126796e 100644 --- a/geolocator_apple/pubspec.yaml +++ b/geolocator_apple/pubspec.yaml @@ -22,8 +22,7 @@ flutter: dependencies: flutter: sdk: flutter - geolocator_platform_interface: - path: ../geolocator_platform_interface + geolocator_platform_interface: ^4.3.0 dev_dependencies: async: ^2.8.2 diff --git a/geolocator_apple/test/geolocator_apple_test.dart b/geolocator_apple/test/geolocator_apple_test.dart index b727b1941..f0752e5e1 100644 --- a/geolocator_apple/test/geolocator_apple_test.dart +++ b/geolocator_apple/test/geolocator_apple_test.dart @@ -4,6 +4,7 @@ import 'package:async/async.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:geolocator_apple/geolocator_apple.dart'; +import 'package:geolocator_platform_interface/geolocator_platform_interface.dart'; import 'event_channel_mock.dart'; import 'method_channel_mock.dart'; @@ -897,6 +898,40 @@ void main() { streamController.close(); }); + test( + // ignore: lines_longer_than_80_chars + 'Should receive a location signal lost exception if location signal is lost', + () async { + // Arrange + final streamController = + StreamController.broadcast(); + EventChannelMock( + channelName: 'flutter.baseflow.com/geolocator_updates_apple', + stream: streamController.stream, + ); + + // Act + final positionStream = GeolocatorApple().getPositionStream(); + final streamQueue = StreamQueue(positionStream); + + // Emit test error + streamController.addError(PlatformException( + code: 'LOCATION_SIGNAL_LOST', + message: 'Location signal lost', + details: null)); + + // Assert + expect( + streamQueue.next, + throwsA( + isA(), + )); + + // Clean up + streamQueue.cancel(); + streamController.close(); + }); + test( // ignore: lines_longer_than_80_chars 'Should receive a already subscribed exception', () async { diff --git a/geolocator_platform_interface/pubspec.yaml b/geolocator_platform_interface/pubspec.yaml index 736507cc5..e2bee6c37 100644 --- a/geolocator_platform_interface/pubspec.yaml +++ b/geolocator_platform_interface/pubspec.yaml @@ -3,7 +3,7 @@ description: A common platform interface for the geolocator plugin. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator_platform_interface # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 4.2.4 +version: 4.3.0 dependencies: flutter: diff --git a/geolocator_platform_interface/test/src/implementations/method_channel_geolocator_test.dart b/geolocator_platform_interface/test/src/implementations/method_channel_geolocator_test.dart index b313a0ce3..4bb37e1c5 100644 --- a/geolocator_platform_interface/test/src/implementations/method_channel_geolocator_test.dart +++ b/geolocator_platform_interface/test/src/implementations/method_channel_geolocator_test.dart @@ -891,6 +891,39 @@ void main() { streamController.close(); }); + test( + 'Should receive a location signal lost exception when location signal is lost', + () async { + // Arrange + final streamController = + StreamController.broadcast(); + EventChannelMock( + channelName: 'flutter.baseflow.com/geolocator_updates', + stream: streamController.stream, + ); + + // Act + final positionStream = MethodChannelGeolocator().getPositionStream(); + final streamQueue = StreamQueue(positionStream); + + // Emit test error + streamController.addError(PlatformException( + code: 'LOCATION_SIGNAL_LOST', + message: 'Location signal lost', + details: null)); + + // Assert + expect( + streamQueue.next, + throwsA( + isA(), + )); + + // Clean up + streamQueue.cancel(); + streamController.close(); + }); + test('Should receive a permission request in progress exception', () async { // Arrange From 95e181a768c298302ed3742b5a3139ae8a6aecd1 Mon Sep 17 00:00:00 2001 From: Orkun Duman Date: Mon, 9 Dec 2024 00:45:42 -0500 Subject: [PATCH 3/4] Add changelog entries --- geolocator/CHANGELOG.md | 4 ++++ geolocator/pubspec.yaml | 8 ++++---- geolocator_android/CHANGELOG.md | 4 ++++ geolocator_android/pubspec.yaml | 2 +- geolocator_apple/CHANGELOG.md | 4 ++++ geolocator_apple/pubspec.yaml | 2 +- geolocator_platform_interface/CHANGELOG.md | 4 ++++ 7 files changed, 22 insertions(+), 6 deletions(-) diff --git a/geolocator/CHANGELOG.md b/geolocator/CHANGELOG.md index dfe7dcd9f..a1ba2d5bf 100644 --- a/geolocator/CHANGELOG.md +++ b/geolocator/CHANGELOG.md @@ -1,3 +1,7 @@ +## 13.1.0 + +* Position update stream may now throw `LocationSignalLostException` when GPS signal is lost. This new exception is safe to catch & ignore. + ## 13.0.2 - Updates dependency on geolocator_apple to version 2.3.8. diff --git a/geolocator/pubspec.yaml b/geolocator/pubspec.yaml index 12d08022b..e66db61bc 100644 --- a/geolocator/pubspec.yaml +++ b/geolocator/pubspec.yaml @@ -2,7 +2,7 @@ name: geolocator description: Geolocation plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API for generic location (GPS etc.) functions. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen -version: 13.0.2 +version: 13.1.0 environment: sdk: ">=2.15.0 <4.0.0" @@ -26,9 +26,9 @@ dependencies: flutter: sdk: flutter - geolocator_platform_interface: ^4.2.3 - geolocator_android: ^4.6.0 - geolocator_apple: ^2.3.8 + geolocator_platform_interface: ^4.3.0 + geolocator_android: ^4.7.0 + geolocator_apple: ^2.4.0 geolocator_web: ^4.1.1 geolocator_windows: ^0.2.3 diff --git a/geolocator_android/CHANGELOG.md b/geolocator_android/CHANGELOG.md index b0e5ab352..a5461cc25 100644 --- a/geolocator_android/CHANGELOG.md +++ b/geolocator_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.7.0 + +* Posiiton stream now throws `LocationSignalLostException` when GPS signal is lost. This new exception is safe to ignore. + ## 4.6.1 * Fixes a bug where the plugin throws an exception while requesting locations updates with coarse location permission only. diff --git a/geolocator_android/pubspec.yaml b/geolocator_android/pubspec.yaml index 0ab9bacdb..ce5ad8658 100644 --- a/geolocator_android/pubspec.yaml +++ b/geolocator_android/pubspec.yaml @@ -2,7 +2,7 @@ name: geolocator_android description: Geolocation plugin for Flutter. This plugin provides the Android implementation for the geolocator. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator_android issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen -version: 4.6.1 +version: 4.7.0 environment: sdk: ">=2.15.0 <4.0.0" diff --git a/geolocator_apple/CHANGELOG.md b/geolocator_apple/CHANGELOG.md index a62b2666e..a5610e1bc 100644 --- a/geolocator_apple/CHANGELOG.md +++ b/geolocator_apple/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.4.0 + +* Posiiton stream now throws `LocationSignalLostException` when GPS signal is lost. This new exception is safe to ignore. + ## 2.3.8+1 * HOT FIX: Adds back implementation of the `stopListening` method in the `GeolocationHandler.m` file. diff --git a/geolocator_apple/pubspec.yaml b/geolocator_apple/pubspec.yaml index cc126796e..072c65395 100644 --- a/geolocator_apple/pubspec.yaml +++ b/geolocator_apple/pubspec.yaml @@ -2,7 +2,7 @@ name: geolocator_apple description: Geolocation Apple plugin for Flutter. This plugin provides the Apple implementation for the geolocator. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator_apple issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen -version: 2.3.8+1 +version: 2.4.0 environment: sdk: ">=2.15.0 <4.0.0" diff --git a/geolocator_platform_interface/CHANGELOG.md b/geolocator_platform_interface/CHANGELOG.md index 245e8e0a8..0b3856aae 100644 --- a/geolocator_platform_interface/CHANGELOG.md +++ b/geolocator_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.3.0 + +* Adds `LocationSignalLostException` which can be thrown when GPS signal is lost. + ## 4.2.4 - Correctly handle integer-like numbers when decoding `Position` from JSON. From fc3d8f1e9bf8a7e61554818b11f0e54d697e12bd Mon Sep 17 00:00:00 2001 From: Orkun Duman Date: Mon, 9 Dec 2024 00:52:27 -0500 Subject: [PATCH 4/4] Adds documentation to getPositionStream API --- geolocator/lib/geolocator.dart | 3 +++ .../lib/src/geolocator_platform_interface.dart | 3 +++ 2 files changed, 6 insertions(+) diff --git a/geolocator/lib/geolocator.dart b/geolocator/lib/geolocator.dart index 008796a3c..5e60ac37e 100644 --- a/geolocator/lib/geolocator.dart +++ b/geolocator/lib/geolocator.dart @@ -185,6 +185,9 @@ class Geolocator { /// supplied [timeLimit] duration. /// Throws a [LocationServiceDisabledException] when the user allowed access, /// but the location services of the device are disabled. + /// Throws a [LocationSignalLostException] when the location/GPS signal is + /// lost. The caller should catch this exception and is free to ignore it. The + /// stream will continue to emit location updates when the signal is restored. static Stream getPositionStream({ LocationSettings? locationSettings, }) => diff --git a/geolocator_platform_interface/lib/src/geolocator_platform_interface.dart b/geolocator_platform_interface/lib/src/geolocator_platform_interface.dart index e16e8ff08..f9aa74e4d 100644 --- a/geolocator_platform_interface/lib/src/geolocator_platform_interface.dart +++ b/geolocator_platform_interface/lib/src/geolocator_platform_interface.dart @@ -166,6 +166,9 @@ abstract class GeolocatorPlatform extends PlatformInterface { /// location when the user denied access. /// Throws a [LocationServiceDisabledException] when the user allowed access, /// but the location services of the device are disabled. + /// Throws a [LocationSignalLostException] when the location/GPS signal is + /// lost. The caller should catch this exception and is free to ignore it. The + /// stream will continue to emit location updates when the signal is restored. Stream getPositionStream({ LocationSettings? locationSettings, }) {