Create a Search Experience
Show a List of Search Results
void search(String value) {
// we should not search when the searchbar is empty
if (value.isEmpty) {
return;
}
// make a query with the search text
MPQuery query = (MPQueryBuilder()..setQuery(value)).build();
// we just want to see the top 30 results, as not to be overwhelmed
MPFilter filter = (MPFilterBuilder()..setTake(30)).build();
// fetch all (max 30) locations that match the query
getLocationsByQuery(query: query, filter: filter).then((locations) {
if (locations != null && locations.isNotEmpty) {
// add UI handling here
}
}).catchError((err) {
// handle the error, for now just show a snackbar
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Search failed: $err"),
backgroundColor: Colors.red,
));
});
}Filter Locations on Map Based on Search Results

Last updated
Was this helpful?