Skip to content

Commit ed42599

Browse files
Floris SmitFloris Smit
Floris Smit
authored and
Floris Smit
committed
On the native platforms, an integer is returned instead of a boolean, getServiceStatusStream implementation changed
1 parent 5c38ca7 commit ed42599

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/// Describes the current state of the location service on the native platform.
22
enum ServiceStatus {
3-
/// Indicates that the location service on the native platform is enabled.
4-
enabled,
5-
63
/// Indicates that the location service on the native platform is enabled.
74
disabled,
5+
/// Indicates that the location service on the native platform is enabled.
6+
enabled,
87
}

geolocator_platform_interface/lib/src/implementations/method_channel_geolocator.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:async';
22

3+
import 'package:flutter/cupertino.dart';
34
import 'package:flutter/services.dart';
45

56
import '../../geolocator_platform_interface.dart';
@@ -136,8 +137,7 @@ class MethodChannelGeolocator extends GeolocatorPlatform {
136137
_serviceStatusEventChannel.receiveBroadcastStream();
137138

138139
_serviceStatusStream = serviceStatusStream
139-
.map((dynamic element) =>
140-
element as bool ? ServiceStatus.enabled : ServiceStatus.disabled)
140+
.map((dynamic element) => ServiceStatus.values[element as int])
141141
.handleError((error) {
142142
_serviceStatusStream = null;
143143
if (error is PlatformException) {

geolocator_platform_interface/test/src/implementations/method_channel_geolocator_test.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ void main() {
583583
'Should receive a stream with location service updates if permissions are granted',
584584
() async {
585585
// Arrange
586-
final streamController = StreamController<bool>.broadcast();
586+
final streamController = StreamController<int>.broadcast();
587587
EventChannelMock(
588588
channelName: 'flutter.baseflow.com/geolocator_service_updates',
589589
stream: streamController.stream);
@@ -594,12 +594,12 @@ void main() {
594594
final streamQueue = StreamQueue(locationServiceStream);
595595

596596
// Emit test events
597-
streamController.add(true);
598-
streamController.add(false);
597+
streamController.add(0); // disabled value in native enum
598+
streamController.add(1); // enabled value in native enum
599599

600600
//Assert
601-
expect(await streamQueue.next, ServiceStatus.enabled);
602601
expect(await streamQueue.next, ServiceStatus.disabled);
602+
expect(await streamQueue.next, ServiceStatus.enabled);
603603

604604
// Clean up
605605
await streamQueue.cancel();

0 commit comments

Comments
 (0)