getPlaces static method
Implementation
static Future<List<Prediction>> getPlaces(String placeName, String mapsKey,
{String? otherOptions}) async {
/// referenceUrl = https://developers.google.com/maps/documentation/places/web-service/autocomplete#maps_http_places_autocomplete_amoeba-txt;
String mapOptions =
['input=$placeName', 'key=$mapsKey', otherOptions].join('&');
http.Response response = await http.get(Uri.parse(
"https://maps.googleapis.com/maps/api/place/autocomplete/json?$mapOptions"));
debugPrint(response.body.toString());
if (response.statusCode == 200) {
Predictions predictions = predictionsFromJson(response.body);
if (predictions.predictions != null) {
return predictions.predictions ?? [];
}
} else {
debugPrint(response.statusCode.toString());
}
return [];
}