Skip to content

Commit cb6849f

Browse files
committed
Added geocoding locale to the Android example app
1 parent 518d8bf commit cb6849f

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

geocoding_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.3.0
2+
3+
* Added `setLocaleIdentifier` to the Android example app.
4+
15
## 3.2.0
26

37
* Exposes isPresent() call that returns true if there is a geocoder implementation present that may return results.

geocoding_android/example/lib/plugin_example/geocode_page.dart

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
1515
final TextEditingController _longitudeController = TextEditingController();
1616
String _output = '';
1717

18+
GeocodingAndroid _geocodingAndroid = GeocodingAndroid();
19+
1820
@override
1921
void initState() {
2022
_addressController.text = 'Gronausestraat 710, Enschede';
@@ -74,7 +76,7 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
7476
final latitude = double.parse(_latitudeController.text);
7577
final longitude = double.parse(_longitudeController.text);
7678

77-
GeocodingAndroid()
79+
_geocodingAndroid
7880
.placemarkFromCoordinates(latitude, longitude)
7981
.then((placemarks) {
8082
var output = 'No results found.';
@@ -107,7 +109,7 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
107109
child: ElevatedButton(
108110
child: Text('Look up address'),
109111
onPressed: () {
110-
GeocodingAndroid()
112+
_geocodingAndroid
111113
.placemarkFromAddress(_addressController.text)
112114
.then((locations) {
113115
var output = 'No results found.';
@@ -140,7 +142,7 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
140142
child: ElevatedButton(
141143
child: Text('Look up location'),
142144
onPressed: () {
143-
GeocodingAndroid()
145+
_geocodingAndroid
144146
.locationFromAddress(_addressController.text)
145147
.then((locations) {
146148
var output = 'No results found.';
@@ -161,7 +163,7 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
161163
child: ElevatedButton(
162164
child: Text('Is present'),
163165
onPressed: () {
164-
GeocodingAndroid().isPresent().then((isPresent) {
166+
_geocodingAndroid.isPresent().then((isPresent) {
165167
var output = isPresent
166168
? "Geocoder is present"
167169
: "Geocoder is not present";
@@ -171,6 +173,31 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
171173
});
172174
}),
173175
),
176+
const Padding(
177+
padding: EdgeInsets.only(top: 8),
178+
),
179+
Center(
180+
child: ElevatedButton(
181+
child: Text('Set locale en_US'),
182+
onPressed: () {
183+
_geocodingAndroid.setLocaleIdentifier("en_US").then((_) {
184+
//locale set
185+
});
186+
})),
187+
const Padding(
188+
padding: EdgeInsets.only(top: 8),
189+
),
190+
Center(
191+
child: ElevatedButton(
192+
child: Text('Set locale nl_NL'),
193+
onPressed: () {
194+
_geocodingAndroid.setLocaleIdentifier("nl_NL").then((_) {
195+
//locale set
196+
});
197+
})),
198+
const Padding(
199+
padding: EdgeInsets.only(top: 8),
200+
),
174201
Expanded(
175202
child: SingleChildScrollView(
176203
child: Container(

0 commit comments

Comments
 (0)