Changed the CHANGELOG and the pubspec.yaml, and added an enum value for android to the LocationAccuracyStatus enum
MODIFY
geolocator_platform_interface/CHANGELOG.md
geolocator_platform_interface/CHANGELOG.md
+## 2.2.1
+
+- Documentation `getLocationAccuracy()` method clarified
+- On Android devices, `getLocationAccuracy()` now returns a LocationAccuracyStatus.unknown value
+
## 2.2.0
- Added the possibility to query for the LocationAccuracyStatus on devices running iOS 14.0 and higher.

MODIFY
geolocator_platform_interface/lib/src/enums/location_accuracy_status.dart
geolocator_platform_interface/lib/src/enums/location_accuracy_status.dart
@@ -5,4 +5,9 @@ enum LocationAccuracyStatus {
/// The precise location of the device will be returned.
precise,
+
+ /// When an Android device is used, an 'unknown' status is returned, since
+ /// Android does not support Approximate Location yet.
+ unknown,
+
}

MODIFY
geolocator_platform_interface/lib/src/geolocator_platform_interface.dart
geolocator_platform_interface/lib/src/geolocator_platform_interface.dart
@@ -159,12 +159,14 @@ abstract class GeolocatorPlatform extends PlatformInterface {
throw UnimplementedError('getPositionStream() has not been implemented.');
}
- /// Returns a [Future] containing a [LocationAccuracyStatus].
+ /// Returns a [Future] containing a [LocationAccuracyStatus] (iOS only).
///
/// When on iOS the user has given permission for approximate location,
/// [LocationAccuracyStatus.reduced] will be returned, if the user gave
/// permission for precise/full accuracy location, [LocationAccuracyStatus.precise]
/// will be returned.
+ /// When executing the method on Android device's,
+ /// [LocationAccuracyStatus.unknown] will be returned.
Future<LocationAccuracyStatus> getLocationAccuracy() async {
throw UnimplementedError('getLocationAccuracy() has not been implemented.');
}

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/foundation.dart';
import 'package:flutter/services.dart';
import '../../geolocator_platform_interface.dart';
@@ -92,6 +93,9 @@ class MethodChannelGeolocator extends GeolocatorPlatform {
@override
Future<LocationAccuracyStatus> getLocationAccuracy() async {
+ if (defaultTargetPlatform == TargetPlatform.iOS) {
+ return LocationAccuracyStatus.unknown;
+ }
final int accuracy =
await _methodChannel.invokeMethod('getLocationAccuracy');
return LocationAccuracyStatus.values[accuracy];

MODIFY
geolocator_platform_interface/pubspec.yaml
geolocator_platform_interface/pubspec.yaml
@@ -3,7 +3,7 @@ description: A common platform interface for the geolocator plugin.
homepage: https://github.com/baseflow/flutter-geolocator
# 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: 2.2.0
+version: 2.2.1
dependencies:
flutter:

MODIFY
geolocator_platform_interface/test/src/implementations/method_channel_geolocator_test.dart
geolocator_platform_interface/test/src/implementations/method_channel_geolocator_test.dart
@@ -136,8 +136,7 @@ void main() {
group('getLocationAccuracy: When requesting the Location Accuracy Status',
() {
- test(
- 'Should receive reduced accuracy if Location Accuracy is reduced',
+ test('Should receive reduced accuracy if Location Accuracy is reduced',
() async {
// Arrange
MethodChannelMock(
@@ -154,8 +153,7 @@ void main() {
expect(locationAccuracy, LocationAccuracyStatus.reduced);
});
- test(
- 'Should receive reduced accuracy if Location Accuracy is reduced',
+ test('Should receive reduced accuracy if Location Accuracy is reduced',
() async {
// Arrange
MethodChannelMock(
@@ -172,6 +170,22 @@ void main() {
expect(locationAccuracy, LocationAccuracyStatus.precise);
});
+ test('Should receive reduced accuracy if Location Accuracy is reduced',
+ () async {
+ // Arrange
+ MethodChannelMock(
+ channelName: 'flutter.baseflow.com/geolocator',
+ method: 'getLocationAccuracy',
+ result: 2,
+ );
+
+ // Act
+ final locationAccuracy =
+ await MethodChannelGeolocator().getLocationAccuracy();
+
+ // Assert
+ expect(locationAccuracy, LocationAccuracyStatus.unknown);
+ });
});
group('requestPermission: When requesting for permission', () {

Changed the CHANGELOG and the pubspec.yaml, and added an enum value for android to the LocationAccuracyStatus enum