getFlightDates method

Future<List<String>?> getFlightDates(
  1. FlightSearchByEnum searchBy,
  2. String searchParam, {
  3. DateTime? fromLocal,
  4. DateTime? toLocal,
})

Flight departure dates TIER 2

On which days the flight operates? or What is the flight schedule? Flight can be searched by: * flight number it's being operated under; or * ATC-callsign it's being operated under; or * tail-number of the aircraft it's being operated by; or * Mode-S 24-bit ICAO Transponder address of the aircraft it's being operated by. Returns: Array of local departure dates in (YYYY-MM-DD) format for flights operated under speified call-sign and within the time range specified.

Parameters:

  • FlightSearchByEnum searchBy (required): Criteria to search flight by

  • String searchParam (required): Value of the search criteria. If searchBy is: * number, then this field shoud be Flight number (with or without spaces, IATA or ICAO, any case formats are acceptable, e.g. KL1395, Klm 1395) * callsign, then this field should be ATC call-sign of the flight (with or without spaces, any case formats are acceptable, e.g.AFL1482, nca 008X); * reg: then this field should be Aircraft tail-number (with or without spaces or dashes, any case formats are acceptable, e.g.PH-BXO, DeMhJ); * icao24, then this field should be Aircraft ICAO 24-bit Mode-S address specified in hexadecimal format (e.g. 484161, 483EFD).

  • DateTime fromLocal: Beginning of the search range (local time, format: YYYY-MM-DD)

  • DateTime toLocal: End of the search range (local time, format: YYYY-MM-DD)

Implementation

Future<List<String>?> getFlightDates(
  FlightSearchByEnum searchBy,
  String searchParam, {
  DateTime? fromLocal,
  DateTime? toLocal,
}) async {
  final response = await getFlightDatesWithHttpInfo(
    searchBy,
    searchParam,
    fromLocal: fromLocal,
    toLocal: toLocal,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty &&
      response.statusCode != HttpStatus.noContent) {
    final responseBody = await _decodeBodyBytes(response);
    return (await apiClient.deserializeAsync(responseBody, 'List<String>')
            as List)
        .cast<String>()
        .toList(growable: false);
  }
  return null;
}