fromJson static method
Returns a new AirportContract instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static AirportContract? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key),
'Required key "AirportContract[$key]" is missing from JSON.');
assert(json[key] != null,
'Required key "AirportContract[$key]" has a null value in JSON.');
});
return true;
}());
return AirportContract(
fullName: mapValueOfType<String>(json, r'fullName')!,
location: GeoCoordinatesContract.fromJson(json[r'location'])!,
elevation: Distance.fromJson(json[r'elevation'])!,
country: AirportCountryContract.fromJson(json[r'country'])!,
continent: AirportContinentContract.fromJson(json[r'continent'])!,
timeZone: mapValueOfType<String>(json, r'timeZone')!,
urls: AirportContractUrls.fromJson(json[r'urls'])!,
icao: mapValueOfType<String>(json, r'icao'),
iata: mapValueOfType<String>(json, r'iata'),
localCode: mapValueOfType<String>(json, r'localCode'),
shortName: mapValueOfType<String>(json, r'shortName'),
municipalityName: mapValueOfType<String>(json, r'municipalityName'),
runways: RunwayContract.listFromJson(json[r'runways']),
currentTime: AirportContractCurrentTime.fromJson(json[r'currentTime']),
);
}
return null;
}