Skip to content

Commit

Permalink
fix error of Geolocator.getServiceStatusStream() on web (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
tlserver committed Feb 7, 2024
1 parent abdaf2d commit fb92d5b
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/src/data/data_stream_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,20 @@ class LocationMarkerDataStreamFactory {
}
} on Exception catch (_) {}
try {
final subscription =
Geolocator.getServiceStatusStream().listen((serviceStatus) {
if (serviceStatus == ServiceStatus.enabled) {
streamController.sink.add(null);
} else {
streamController.sink
.addError(const ServiceDisabledException());
}
});
cancelFunctions.add(subscription.cancel);
// The concept of location service doesn't exist on the web
// platform
if (!kIsWeb) {
final subscription = Geolocator.getServiceStatusStream()
.listen((serviceStatus) {
if (serviceStatus == ServiceStatus.enabled) {
streamController.sink.add(null);
} else {
streamController.sink
.addError(const ServiceDisabledException());
}
});
cancelFunctions.add(subscription.cancel);
}
} on Exception catch (_) {}
try {
final lastKnown = await Geolocator.getLastKnownPosition();
Expand Down

0 comments on commit fb92d5b

Please sign in to comment.