flightsSearch method

Future<FlightSearchResult?> flightsSearch({
  1. FlightSearchRequest? flightSearchRequest,
  2. Future<void>? abortTrigger,
})

Search flights

Searches flight itineraries and the fares bookable on them. Send one slice per flight (one for one-way, two for a return, more for a multi-city trip) and every passenger; at least one passenger must be an adult, and children and infants need an age. Optional filters: maxStops, preferredAirlines and excludedAirlines select itineraries; refundableOnly and maxPrice select fares, and an itinerary left without a fare is not returned. The body rejects an unknown field at every level, and the route takes no query parameters. Returns { items, pagination }. Each item is one itinerary, the same flights sold by the same airline, with its fares as offers, cheapest first; items are ordered by their cheapest fare, then total duration. page and limit (defaults 1 and 10, limit at most 100) page through itineraries, and pagination.totalCount counts them. Each page runs a new airline search, so fares can change between pages. An item's id is valid only within this response and cannot be ordered; quote and order an offer's publicId before its details.expiresAt. Prices are for all passengers, in currency or the API key's currency, and are indicative. Errors: an invalid or unknown field, or a query parameter, 400 / 10001; an unsupported currency 404 / 10004.

Parameters:

Implementation

Future<FlightSearchResult?> flightsSearch({ FlightSearchRequest? flightSearchRequest, Future<void>? abortTrigger, }) async {
  final response = await flightsSearchWithHttpInfo(flightSearchRequest: flightSearchRequest, abortTrigger: abortTrigger,);
  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) {
    return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'FlightSearchResult',) as FlightSearchResult;

  }
  return null;
}