Skip to content

Commit

Permalink
Added geocoding locale to the Android example app (#211)
Browse files Browse the repository at this point in the history
* Added geocoding locale to the Android example app

* added new version to the pubspec
  • Loading branch information
TimHoogstrate authored Mar 8, 2024
1 parent da17019 commit b2aa67b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
4 changes: 4 additions & 0 deletions geocoding_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.3.0

* Added `setLocaleIdentifier` to the Android example app.

## 3.2.0

* Exposes isPresent() call that returns true if there is a geocoder implementation present that may return results.
Expand Down
35 changes: 31 additions & 4 deletions geocoding_android/example/lib/plugin_example/geocode_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
final TextEditingController _longitudeController = TextEditingController();
String _output = '';

GeocodingAndroid _geocodingAndroid = GeocodingAndroid();

@override
void initState() {
_addressController.text = 'Gronausestraat 710, Enschede';
Expand Down Expand Up @@ -74,7 +76,7 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
final latitude = double.parse(_latitudeController.text);
final longitude = double.parse(_longitudeController.text);

GeocodingAndroid()
_geocodingAndroid
.placemarkFromCoordinates(latitude, longitude)
.then((placemarks) {
var output = 'No results found.';
Expand Down Expand Up @@ -107,7 +109,7 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
child: ElevatedButton(
child: Text('Look up address'),
onPressed: () {
GeocodingAndroid()
_geocodingAndroid
.placemarkFromAddress(_addressController.text)
.then((locations) {
var output = 'No results found.';
Expand Down Expand Up @@ -140,7 +142,7 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
child: ElevatedButton(
child: Text('Look up location'),
onPressed: () {
GeocodingAndroid()
_geocodingAndroid
.locationFromAddress(_addressController.text)
.then((locations) {
var output = 'No results found.';
Expand All @@ -161,7 +163,7 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
child: ElevatedButton(
child: Text('Is present'),
onPressed: () {
GeocodingAndroid().isPresent().then((isPresent) {
_geocodingAndroid.isPresent().then((isPresent) {
var output = isPresent
? "Geocoder is present"
: "Geocoder is not present";
Expand All @@ -171,6 +173,31 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
});
}),
),
const Padding(
padding: EdgeInsets.only(top: 8),
),
Center(
child: ElevatedButton(
child: Text('Set locale en_US'),
onPressed: () {
_geocodingAndroid.setLocaleIdentifier("en_US").then((_) {
//locale set
});
})),
const Padding(
padding: EdgeInsets.only(top: 8),
),
Center(
child: ElevatedButton(
child: Text('Set locale nl_NL'),
onPressed: () {
_geocodingAndroid.setLocaleIdentifier("nl_NL").then((_) {
//locale set
});
})),
const Padding(
padding: EdgeInsets.only(top: 8),
),
Expanded(
child: SingleChildScrollView(
child: Container(
Expand Down
2 changes: 1 addition & 1 deletion geocoding_android/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: geocoding_android
description: A Flutter Geocoding plugin which provides easy geocoding and reverse-geocoding features.
version: 3.2.0
version: 3.3.0
repository: https://github.com/baseflow/flutter-geocoding/tree/main/geocoding_android
issue_tracker: https://github.com/Baseflow/flutter-geocoding/issues

Expand Down

0 comments on commit b2aa67b

Please sign in to comment.