findPlaces method
Method to search for places based on a query string
Implementation
@override
Future<List<Place>> findPlaces(String queryString) async {
// Perform the search using the GoogleMapsPlaces API
final response = await googleMapsPlaces.searchByText(
queryString,
language: PlatformDispatcher.instance.locale.languageCode,
);
// Filter the results to those with valid geometry data
final places = response.results.where((place) => place.geometry != null);
// Convert the filtered results to Place objects
return places.map<Place>(
(place) {
return Place(
name: place.name,
address: place.formattedAddress ?? '',
location: LatLng(
place.geometry!.location.lat,
place.geometry!.location.lng,
),
iconImage: place.icon,
);
},
).toList();
}