I am currently working on an app that uses google places autocomplete to find addresses around the world. I have implemented it in the following way:
Position currentPosition;
var placeId, address;
double lat, lng;
getCurrentLocation(){
final Geolocator geolocator = Geolocator()..forceAndroidLocationManager;
geolocator
.getCurrentPosition(desiredAccuracy: LocationAccuracy.best)
.then((Position position){
setState(() {
currentPosition = position;
});
}).catchError((e){
print(e);
});
}
Future<Null> displayPrediction(Prediction p) async {
if (p != null) {
PlacesDetailsResponse detail = await _places.getDetailsByPlaceId(p.placeId);
placeId = p.placeId;
lat = detail.result.geometry.location.lat;
lng = detail.result.geometry.location.lng;
address = await Geocoder.local.findAddressesFromQuery(p.description);
}
}
onPressed: () async {
print(currentPosition.latitude);
print(currentPosition.longitude);
Prediction prediction = await PlacesAutocomplete.show(
context: context,
apiKey: googleApiKey,
location: Location(currentPosition.latitude, currentPosition.longitude),
radius: 100000000,
mode: Mode.overlay,
language: "en",
);
However, whenever I type something into the search bar, I do not receive any autocompleted results and I am not sure why (image attached). If it makes any difference, I am using the iOS simulator. I haven't yet tested on Android. Any help would be much appreciated.