1 year ago
#258605
Moez Elahi
Flutter Google Places Autocomplete only for Localities and Sub Localities
I want to get the suggestions through Google Places API only for Localities and Sublocalities and nothing else.
I read the documentation on the Google Places Website and it seems that this is impossible. All searches also give suggestions on Provinces, Countries, Postal Codes and etc.
Please find my snippet below:
void getSuggestion(String input) async {
String kPLACES_API_KEY = "API_KEY";
String type = '(region)';
String baseURL =
'https://maps.googleapis.com/maps/api/place/autocomplete/json';
String request =
'$baseURL?input=$input&key=$kPLACES_API_KEY&sessiontoken=$_sessionToken&types=$type';
var response = await http.get(Uri.parse(request));
if (response.statusCode == 200) {
setState(() {
_placeList = json.decode(response.body)['predictions'];
});
} else {
throw Exception('Failed to load predictions');
}
}
Is there any workaround for this?
flutter
google-maps
google-cloud-platform
google-places-api
google-places
0 Answers
Your Answer