@@ -15,6 +15,8 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
15
15
final TextEditingController _longitudeController = TextEditingController ();
16
16
String _output = '' ;
17
17
18
+ GeocodingAndroid _geocodingAndroid = GeocodingAndroid ();
19
+
18
20
@override
19
21
void initState () {
20
22
_addressController.text = 'Gronausestraat 710, Enschede' ;
@@ -74,7 +76,7 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
74
76
final latitude = double .parse (_latitudeController.text);
75
77
final longitude = double .parse (_longitudeController.text);
76
78
77
- GeocodingAndroid ()
79
+ _geocodingAndroid
78
80
.placemarkFromCoordinates (latitude, longitude)
79
81
.then ((placemarks) {
80
82
var output = 'No results found.' ;
@@ -107,7 +109,7 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
107
109
child: ElevatedButton (
108
110
child: Text ('Look up address' ),
109
111
onPressed: () {
110
- GeocodingAndroid ()
112
+ _geocodingAndroid
111
113
.placemarkFromAddress (_addressController.text)
112
114
.then ((locations) {
113
115
var output = 'No results found.' ;
@@ -140,7 +142,7 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
140
142
child: ElevatedButton (
141
143
child: Text ('Look up location' ),
142
144
onPressed: () {
143
- GeocodingAndroid ()
145
+ _geocodingAndroid
144
146
.locationFromAddress (_addressController.text)
145
147
.then ((locations) {
146
148
var output = 'No results found.' ;
@@ -161,7 +163,7 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
161
163
child: ElevatedButton (
162
164
child: Text ('Is present' ),
163
165
onPressed: () {
164
- GeocodingAndroid () .isPresent ().then ((isPresent) {
166
+ _geocodingAndroid .isPresent ().then ((isPresent) {
165
167
var output = isPresent
166
168
? "Geocoder is present"
167
169
: "Geocoder is not present" ;
@@ -171,6 +173,31 @@ class _GeocodeWidgetState extends State<GeocodeWidget> {
171
173
});
172
174
}),
173
175
),
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
+ ),
174
201
Expanded (
175
202
child: SingleChildScrollView (
176
203
child: Container (
0 commit comments