Skip to content

Commit

Permalink
Fixed setting of locale on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
TimHoogstrate committed Mar 4, 2024
1 parent 518d8bf commit b0d3040
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
5 changes: 5 additions & 0 deletions geocoding_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
30 changes: 18 additions & 12 deletions geocoding_ios/lib/geocoding_ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> setLocaleIdentifier(
String localeIdentifier,
) async {
_localeIdentifier = localeIdentifier;
}

@override
Future<List<Location>> locationFromAddress(
String address, {
String? localeIdentifier,
}) async {
Future<List<Location>> locationFromAddress(String address) async {
final parameters = <String, String>{
'address': address,
};

if (localeIdentifier != null) {
parameters['localeIdentifier'] = localeIdentifier;
if (_localeIdentifier != null) {
parameters['localeIdentifier'] = _localeIdentifier!;
}
try {
final placemarks = await _channel.invokeMethod(
Expand All @@ -40,16 +47,15 @@ class GeocodingIOS extends GeocodingPlatform {
@override
Future<List<Placemark>> placemarkFromCoordinates(
double latitude,
double longitude, {
String? localeIdentifier,
}) async {
double longitude,
) async {
final parameters = <String, dynamic>{
'latitude': latitude,
'longitude': longitude,
};

if (localeIdentifier != null) {
parameters['localeIdentifier'] = localeIdentifier;
if (_localeIdentifier != null) {
parameters['localeIdentifier'] = _localeIdentifier!;
}

final placemarks =
Expand Down
2 changes: 1 addition & 1 deletion geocoding_ios/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit b0d3040

Please sign in to comment.