searchAirport method

Future<List<FromAirport>> searchAirport(
  1. String searchString
)

Implementation

Future<List<FromAirport>> searchAirport(String searchString) async {
  try {
    if (searchString.isNotEmpty) {
      var response = await Requests.getDio(showLoadingDialog: false)
          .get('data/airports/search?query=$searchString');

      if (response.statusCode == 200) {
        debugPrint(
            "search airport length: ${(response.data['data'] as List<dynamic>).length}");
        return (response.data['data'] as List<dynamic>)
            .map((e) => FromAirport.fromJson(e))
            .toList();
      } else {
        debugPrint("Error: Airport Search Failed $response");
      }
    }
  } catch (e) {
    debugPrint("Error: Airport Search Failed ${e.toString()}");
  }
  return [];
}