location accuracy method processed in the platform interface
MODIFY
geolocator_platform_interface/CHANGELOG.md
geolocator_platform_interface/CHANGELOG.md
+## 2.2.0
+
+- Added the possibility to query for the LocationAccuracyStatus on iOS devices
+
## 2.1.1
- Solves a bug which resulted in an issue when closing the position stream and requesting a new one (see issue [#703](https://github.com/Baseflow/flutter-geolocator/issues/703)).

MODIFY
geolocator_platform_interface/lib/src/enums/enums.dart
geolocator_platform_interface/lib/src/enums/enums.dart
export 'location_accuracy.dart';
+export 'location_accuracy_status.dart';
export 'location_permission.dart';
export 'location_service.dart';

ADD
geolocator_platform_interface/lib/src/enums/location_accuracy_status.dart
+/// Represent the current Location Accuracy Status on iOS devices
+enum LocationAccuracyStatus {
+ /// A approximate location will be returned (Approximate location)
+ reduced,
+
+ /// The precise location of the device will be returned
+ precise,
+}

MODIFY
geolocator_platform_interface/lib/src/geolocator_platform_interface.dart
geolocator_platform_interface/lib/src/geolocator_platform_interface.dart
@@ -159,6 +159,15 @@ abstract class GeolocatorPlatform extends PlatformInterface {
throw UnimplementedError('getPositionStream() has not been implemented.');
}
+ /// Returns a [Future] containing a [LocationAccuracyStatus]
+ /// 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
+ Future<LocationAccuracyStatus> getLocationAccuracy() async {
+ throw UnimplementedError('getLocationAccuracy() has not been implemented.');
+ }
+
/// Opens the App settings page.
///
/// Returns [true] if the app settings page could be opened, otherwise

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/material.dart';
import 'package:flutter/services.dart';
import '../../geolocator_platform_interface.dart';
@@ -90,6 +91,12 @@ class MethodChannelGeolocator extends GeolocatorPlatform {
}
}
+ @override
+ Future<LocationAccuracyStatus> getLocationAccuracy() async {
+ final accuracy = await _methodChannel.invokeMethod('getLocationAccuracy');
+ return LocationAccuracyStatus.values[accuracy as int];
+ }
+
@override
Future<Position> getCurrentPosition({
LocationAccuracy desiredAccuracy = LocationAccuracy.best,

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.1.1
+version: 2.2.0
dependencies:
flutter:

MODIFY
geolocator_platform_interface/test/geolocator_platform_interface_test.dart
geolocator_platform_interface/test/geolocator_platform_interface_test.dart
@@ -101,6 +101,20 @@ void main() {
);
});
+ test(
+ // ignore: lines_longer_than_80_chars
+ 'Default implementation of getLocationAccuracy should throw unimplemented error',
+ () {
+ // Arrange
+ final geolocatorPlatform = ExtendsGeolocatorPlatform();
+
+ // Act & Assert
+ expect(
+ geolocatorPlatform.getLocationAccuracy(),
+ throwsUnimplementedError,
+ );
+ });
+
test(
// ignore: lines_longer_than_80_chars
'Default implementation of getServiceStatusStream should throw unimplemented error',

MODIFY
geolocator_platform_interface/test/src/implementations/method_channel_geolocator_test.dart
geolocator_platform_interface/test/src/implementations/method_channel_geolocator_test.dart
@@ -134,6 +134,46 @@ void main() {
});
});
+ group('getLocationAccuracy: When requesting the Location Accuracy Status',
+ () {
+ test(
+ 'Should receive reduced accuracy if Location Accuracy is reduced',
+ () async {
+ // Arrange
+ MethodChannelMock(
+ channelName: 'flutter.baseflow.com/geolocator',
+ method: 'getLocationAccuracy',
+ result: 0,
+ );
+
+ // Act
+ final locationAccuracy =
+ await MethodChannelGeolocator().getLocationAccuracy();
+
+ // Assert
+ expect(locationAccuracy, LocationAccuracyStatus.reduced);
+ });
+
+ test(
+ 'Should receive reduced accuracy if Location Accuracy is reduced',
+ () async {
+ // Arrange
+ MethodChannelMock(
+ channelName: 'flutter.baseflow.com/geolocator',
+ method: 'getLocationAccuracy',
+ result: 1,
+ );
+
+ // Act
+ final locationAccuracy =
+ await MethodChannelGeolocator().getLocationAccuracy();
+
+ // Assert
+ expect(locationAccuracy, LocationAccuracyStatus.precise);
+ });
+
+ });
+
group('requestPermission: When requesting for permission', () {
test(
// ignore: lines_longer_than_80_chars

location accuracy method processed in the platform interface