addressSuggestion function

Future<List<SearchInfo>> addressSuggestion(
  1. String searchText, {
  2. int limitInformation = 5,
  3. String locale = "",
})

Implementation

Future<List<SearchInfo>> addressSuggestion(String searchText,
    {int limitInformation = 5, String locale = ""}) async {
  Response response = await Dio().get(
    "https://photon.komoot.io/api/",
    queryParameters: {
      "q": searchText,
      "limit": limitInformation == 0 ? "" : "$limitInformation",
      "lang": locale
    },
  );
  final json = response.data;

  return (json["features"] as List)
      .map((d) => SearchInfo.fromPhotonAPI(d))
      .toList();
}