getFlightDelays method
Flight delay statistics by flight number TIER 3
By how much the flight is delayed in average? Information is only available for flights which were tracked with live updates at least at origin or at destination within the last 90 days. Returns: delay statistics for the flight with specified number.
Parameters:
- String number (required): Flight number (with or without spaces, IATA or ICAO, any case formats are acceptable, e.g. KL1395, Klm 1395)
Implementation
Future<FlightLegDelayContract?> getFlightDelays(
String number,
) async {
final response = await getFlightDelaysWithHttpInfo(
number,
);
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),
'FlightLegDelayContract',
) as FlightLegDelayContract;
}
return null;
}