From b0d304094f30b0ebf5740a5b7d903229ee82f220 Mon Sep 17 00:00:00 2001 From: tim Hoogstrate Date: Mon, 4 Mar 2024 10:58:00 +0100 Subject: [PATCH] Fixed setting of locale on iOS --- geocoding_ios/CHANGELOG.md | 5 +++++ geocoding_ios/lib/geocoding_ios.dart | 30 +++++++++++++++++----------- geocoding_ios/pubspec.yaml | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/geocoding_ios/CHANGELOG.md b/geocoding_ios/CHANGELOG.md index 3cf589b..e33c3e1 100644 --- a/geocoding_ios/CHANGELOG.md +++ b/geocoding_ios/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.4.0 + + * Fixes to configure the locale. + * Removes the `localeIdentifier` argument from all methods. Use method `setLocaleIdentifier` to configure the locale. + ## 2.3.0 * Implements `isPresent` that always returns true. diff --git a/geocoding_ios/lib/geocoding_ios.dart b/geocoding_ios/lib/geocoding_ios.dart index 3c3d290..4c3154f 100644 --- a/geocoding_ios/lib/geocoding_ios.dart +++ b/geocoding_ios/lib/geocoding_ios.dart @@ -5,24 +5,31 @@ import 'package:geocoding_platform_interface/geocoding_platform_interface.dart'; const MethodChannel _channel = MethodChannel('flutter.baseflow.com/geocoding'); -/// An implementation of [GeocodingPlatform] for Android. +/// An implementation of [GeocodingPlatform] for iOS. class GeocodingIOS extends GeocodingPlatform { /// Registers this class as the default instance of [GeocodingPlatform]. static void registerWith() { GeocodingPlatform.instance = GeocodingIOS(); } + // ignore: public_member_api_docs + String? _localeIdentifier; + + @override + Future setLocaleIdentifier( + String localeIdentifier, + ) async { + _localeIdentifier = localeIdentifier; + } + @override - Future> locationFromAddress( - String address, { - String? localeIdentifier, - }) async { + Future> locationFromAddress(String address) async { final parameters = { 'address': address, }; - if (localeIdentifier != null) { - parameters['localeIdentifier'] = localeIdentifier; + if (_localeIdentifier != null) { + parameters['localeIdentifier'] = _localeIdentifier!; } try { final placemarks = await _channel.invokeMethod( @@ -40,16 +47,15 @@ class GeocodingIOS extends GeocodingPlatform { @override Future> placemarkFromCoordinates( double latitude, - double longitude, { - String? localeIdentifier, - }) async { + double longitude, + ) async { final parameters = { 'latitude': latitude, 'longitude': longitude, }; - if (localeIdentifier != null) { - parameters['localeIdentifier'] = localeIdentifier; + if (_localeIdentifier != null) { + parameters['localeIdentifier'] = _localeIdentifier!; } final placemarks = diff --git a/geocoding_ios/pubspec.yaml b/geocoding_ios/pubspec.yaml index c867ab3..2b78ba4 100644 --- a/geocoding_ios/pubspec.yaml +++ b/geocoding_ios/pubspec.yaml @@ -1,6 +1,6 @@ name: geocoding_ios description: A Flutter Geocoding plugin which provides easy geocoding and reverse-geocoding features. -version: 2.3.0 +version: 2.4.0 repository: https://github.com/baseflow/flutter-geocoding/tree/main/geocoding_ios issue_tracker: https://github.com/Baseflow/flutter-geocoding/issues