On the native platforms, an integer is returned instead of a boolean, getServiceStatusStream implementation changed
MODIFY
geolocator_platform_interface/lib/src/enums/location_service.dart
geolocator_platform_interface/lib/src/enums/location_service.dart
/// Describes the current state of the location service on the native platform.
enum ServiceStatus {
- /// Indicates that the location service on the native platform is enabled.
- enabled,
-
/// Indicates that the location service on the native platform is enabled.
disabled,
+ /// Indicates that the location service on the native platform is enabled.
+ enabled,
}

MODIFY
geolocator_platform_interface/lib/src/implementations/method_channel_geolocator.dart
geolocator_platform_interface/lib/src/implementations/method_channel_geolocator.dart
import 'dart:async';
+import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
import '../../geolocator_platform_interface.dart';
@@ -136,8 +137,7 @@ class MethodChannelGeolocator extends GeolocatorPlatform {
_serviceStatusEventChannel.receiveBroadcastStream();
_serviceStatusStream = serviceStatusStream
- .map((dynamic element) =>
- element as bool ? ServiceStatus.enabled : ServiceStatus.disabled)
+ .map((dynamic element) => ServiceStatus.values[element as int])
.handleError((error) {
_serviceStatusStream = null;
if (error is PlatformException) {

MODIFY
geolocator_platform_interface/test/src/implementations/method_channel_geolocator_test.dart
geolocator_platform_interface/test/src/implementations/method_channel_geolocator_test.dart
@@ -583,7 +583,7 @@ void main() {
'Should receive a stream with location service updates if permissions are granted',
() async {
// Arrange
- final streamController = StreamController<bool>.broadcast();
+ final streamController = StreamController<int>.broadcast();
EventChannelMock(
channelName: 'flutter.baseflow.com/geolocator_service_updates',
stream: streamController.stream);
@@ -594,12 +594,12 @@ void main() {
final streamQueue = StreamQueue(locationServiceStream);
// Emit test events
- streamController.add(true);
- streamController.add(false);
+ streamController.add(0); // disabled value in native enum
+ streamController.add(1); // enabled value in native enum
//Assert
- expect(await streamQueue.next, ServiceStatus.enabled);
expect(await streamQueue.next, ServiceStatus.disabled);
+ expect(await streamQueue.next, ServiceStatus.enabled);
// Clean up
await streamQueue.cancel();

On the native platforms, an integer is returned instead of a boolean, getServiceStatusStream implementation changed