diff --git a/geocoding/CHANGELOG.md b/geocoding/CHANGELOG.md index 3a5f76c..bff0495 100644 --- a/geocoding/CHANGELOG.md +++ b/geocoding/CHANGELOG.md @@ -1,3 +1,11 @@ +## 3.0.0 + +* **BREAKING CHANGES**: + - Locale is no longer part of the `locationFromAddress` and `placemarkFromAddress`, but should be set first by `setLocaleIdentifier`. This was already implemented on Android but is now working similarly on iOS. + - Updates documentation related to setting the locale. + - Added `setLocaleIdentifier` to the example app. + - Updates `geocoding_ios` version to 3.0.0. + ## 2.2.2 - Updates documentation for isPresent(). diff --git a/geocoding/README.md b/geocoding/README.md index 1dd7814..5095464 100644 --- a/geocoding/README.md +++ b/geocoding/README.md @@ -57,7 +57,7 @@ import 'package:geocoding/geocoding.dart'; List placemarks = await placemarkFromCoordinates(52.2165157, 6.9437819); ``` -Both the `locationFromAddress` and `placemarkFromCoordinates` accept an optional `localeIdentifier` parameter. This parameter can be used to enforce the results to be formatted (and translated) according to the specified locale. The `localeIdentifier` should be formatted using the syntax: [languageCode]_[countryCode]. Use the [ISO 639-1 or ISO 639-2](http://www.loc.gov/standards/iso639-2/php/English_list.php) standard for the language code and the 2 letter [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard for the country code. Some examples are: +The setLocaleIdentifier with the `localeIdentifier` parameter can be used to enforce the results to be formatted (and translated) according to the specified locale. The `localeIdentifier` should be formatted using the syntax: [languageCode]_[countryCode]. Use the [ISO 639-1 or ISO 639-2](http://www.loc.gov/standards/iso639-2/php/English_list.php) standard for the language code and the 2 letter [ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1) standard for the country code. Some examples are: Locale identifier | Description ----------------- | ----------- diff --git a/geocoding/example/lib/main.dart b/geocoding/example/lib/main.dart index 20f4290..adeb5fb 100644 --- a/geocoding/example/lib/main.dart +++ b/geocoding/example/lib/main.dart @@ -136,6 +136,31 @@ class _GeocodeWidgetState extends State { }); }), ), + const Padding( + padding: EdgeInsets.only(top: 8), + ), + Center( + child: ElevatedButton( + child: Text('Set locale en_US'), + onPressed: () { + setLocaleIdentifier("en_US").then((_) { + setState(() {}); + }); + })), + const Padding( + padding: EdgeInsets.only(top: 8), + ), + Center( + child: ElevatedButton( + child: Text('Set locale nl_NL'), + onPressed: () { + setLocaleIdentifier("nl_NL").then((_) { + setState(() {}); + }); + })), + const Padding( + padding: EdgeInsets.only(top: 8), + ), Expanded( child: SingleChildScrollView( child: Container( diff --git a/geocoding/lib/geocoding.dart b/geocoding/lib/geocoding.dart index 912dc35..d4a2796 100644 --- a/geocoding/lib/geocoding.dart +++ b/geocoding/lib/geocoding.dart @@ -10,15 +10,9 @@ export 'package:geocoding_platform_interface/geocoding_platform_interface.dart'; /// However in some situations where the supplied address could not be /// resolved into a single [Location], multiple [Location] instances may be /// returned. -/// -/// Optionally you can specify a locale in which the results are returned. -/// When not supplied the currently active locale of the device will be used. -/// The `localeIdentifier` should be formatted using the syntax: -/// [languageCode]_[countryCode] (eg. en_US or nl_NL). Future> locationFromAddress( - String address, { - String? localeIdentifier, -}) => + String address, +) => GeocodingPlatform.instance!.locationFromAddress( address, ); @@ -30,21 +24,28 @@ Future> locationFromAddress( /// However in some situations where the supplied coordinates could not be /// resolved into a single [Placemark], multiple [Placemark] instances may be /// returned. -/// -/// Optionally you can specify a locale in which the results are returned. -/// When not supplied the currently active locale of the device will be used. -/// The `localeIdentifier` should be formatted using the syntax: -/// [languageCode]_[countryCode] (eg. en_US or nl_NL). Future> placemarkFromCoordinates( double latitude, - double longitude, { - String? localeIdentifier, -}) => + double longitude, +) => GeocodingPlatform.instance!.placemarkFromCoordinates( latitude, longitude, ); +/// Overrides default locale +/// +/// You can specify a locale in which the results are returned. +/// When not used the current active locale of the device will be used. +/// The `localeIdentifier` should be formatted using the syntax: +/// [languageCode]_[countryCode] (eg. en_US or nl_NL). +Future setLocaleIdentifier( + String localeIdentifier, +) => + GeocodingPlatform.instance!.setLocaleIdentifier( + localeIdentifier, + ); + /// Returns true if there is a geocoder implementation present that may return results. /// If true, there is still no guarantee that any individual geocoding attempt will succeed. /// diff --git a/geocoding/pubspec.yaml b/geocoding/pubspec.yaml index 2c488dc..5ef1d34 100644 --- a/geocoding/pubspec.yaml +++ b/geocoding/pubspec.yaml @@ -1,6 +1,6 @@ name: geocoding description: A Flutter Geocoding plugin which provides easy geocoding and reverse-geocoding features. -version: 2.2.2 +version: 3.0.0 repository: https://github.com/baseflow/flutter-geocoding/tree/main/geocoding issue_tracker: https://github.com/Baseflow/flutter-geocoding/issues @@ -14,7 +14,7 @@ dependencies: geocoding_platform_interface: ^3.0.0 geocoding_android: ^3.0.0 - geocoding_ios: ^2.0.0 + geocoding_ios: ^3.0.0 dev_dependencies: flutter_test: diff --git a/geocoding/test/geocoding_test.dart b/geocoding/test/geocoding_test.dart index 38f2637..9bef63a 100644 --- a/geocoding/test/geocoding_test.dart +++ b/geocoding/test/geocoding_test.dart @@ -48,18 +48,16 @@ class MockGeocodingPlatform extends Mock GeocodingPlatform { @override Future> locationFromAddress( - String address, { - String? localeIdentifier, - }) async { + String address, + ) async { return [mockLocation]; } @override Future> placemarkFromCoordinates( double latitude, - double longitude, { - String? localeIdentifier, - }) async { + double longitude, + ) async { return [mockPlacemark]; } }