search method

Future<List<LocationModel>> search(
  1. String query
)

Implementation

Future<List<LocationModel>> search(String query) async {
  String url =
      "https://maps.googleapis.com/maps/api/place/autocomplete/json?input=$query&location=${currentLocation.latitude},${currentLocation.longitude}t&key=$qKey";

  final response = await http.get(
    Uri.parse(url),
  );

  final json = jsonDecode(response.body);

  searchResult = List<LocationModel>.from(json['predictions'].map(
    (map) => LocationModel(
      latitude: 0,
      longitude: 0,
      address: map['description'],
      placeId: map['place_id'],
    ),
  ));

  notifyListeners();
  return searchResult;
}