PR Change requests merged
MODIFY
geolocator/CHANGELOG.md
geolocator/CHANGELOG.md
## 7.1.0
+
- Added the locationServiceStream which fires an event if the location service of the device are disabled/enabled in the Android/iOS notification bar or in the Settings of the device.
- Updated the `geolocator_platform_interface: 2.1.0`

MODIFY
geolocator/README.md
geolocator/README.md
@@ -190,7 +190,7 @@ StreamSubscription<Position> positionStream = Geolocator.getPositionStream(locat
});
```
-To listen for service status changes you can call the `getServiceStatusStream` to receive stream you can listen to and receive location service status updates.
+To listen for service status changes you can call the `getServiceStatusStream`. This will return a `Stream<ServiceStatus>` which can be listened to, to receive location service status updates.
``` dart
import 'package:geolocator/geolocator.dart';

MODIFY
geolocator/android/src/main/java/com/baseflow/geolocator/GeolocatorPlugin.java
geolocator/android/src/main/java/com/baseflow/geolocator/GeolocatorPlugin.java
package com.baseflow.geolocator;
-import android.location.Location;
-
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-
import com.baseflow.geolocator.location.GeolocationManager;
import com.baseflow.geolocator.permission.PermissionManager;
import io.flutter.embedding.engine.plugins.FlutterPlugin;

MODIFY
geolocator/android/src/main/java/com/baseflow/geolocator/location/LocationServiceStatusReceiver.java
geolocator/android/src/main/java/com/baseflow/geolocator/location/LocationServiceStatusReceiver.java
@@ -5,18 +5,17 @@ import android.content.Context;
import android.content.Intent;
import android.location.LocationManager;
-import androidx.annotation.Nullable;
+import androidx.annotation.NonNull;
import io.flutter.plugin.common.EventChannel;
-
public class LocationServiceStatusReceiver extends BroadcastReceiver {
- @Nullable
+ @NonNull
private final EventChannel.EventSink events;
private boolean isEnabled = false;
- public LocationServiceStatusReceiver(@Nullable Object arguments, @Nullable EventChannel.EventSink events) {
+ public LocationServiceStatusReceiver(@NonNull EventChannel.EventSink events) {
this.events = events;
}
@@ -37,17 +36,13 @@ public class LocationServiceStatusReceiver extends BroadcastReceiver {
*/
if (!isEnabled) {
isEnabled = true;
- if (events != null) {
events.success(ServiceStatus.enabled.ordinal());
}
- }
} else {
if (isEnabled) {
isEnabled = false;
- if (events != null) {
events.success(ServiceStatus.disabled.ordinal());
}
- }
}
}

MODIFY
geolocator/example/lib/main.dart
geolocator/example/lib/main.dart
@@ -201,7 +201,7 @@ class _GeolocatorWidgetState extends State<GeolocatorWidget> {
_locationServiceStatusSubscription?.cancel();
_locationServiceStatusSubscription = null;
}).listen((status) => setState(() => _positionItems.add(_PositionItem(
- _PositionItemType.locationservicestatus, status.toString()))));
+ _PositionItemType.locationServiceStatus, status.toString()))));
_locationServiceStatusSubscription?.pause();
}
@@ -252,7 +252,11 @@ class _GeolocatorWidgetState extends State<GeolocatorWidget> {
}
}
-enum _PositionItemType { permission, position, locationservicestatus }
+enum _PositionItemType {
+ permission,
+ position,
+ locationServiceStatus,
+}
class _PositionItem {
_PositionItem(this.type, this.displayValue);

MODIFY
geolocator/lib/geolocator.dart
geolocator/lib/geolocator.dart
@@ -110,7 +110,6 @@ class Geolocator {
/// location when the user denied access.
/// Throws a [LocationServiceDisabledException] when the user allowed access,
/// but the location services of the device are disabled.
-
static Stream<Position> getPositionStream({
LocationAccuracy desiredAccuracy = LocationAccuracy.best,
int distanceFilter = 0,

PR Change requests merged