fromJson static method
Returns a new AircraftContract instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static AircraftContract? 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 "AircraftContract[$key]" is missing from JSON.');
assert(json[key] != null,
'Required key "AircraftContract[$key]" has a null value in JSON.');
});
return true;
}());
return AircraftContract(
id: mapValueOfType<int>(json, r'id')!,
reg: mapValueOfType<String>(json, r'reg')!,
active: mapValueOfType<bool>(json, r'active')!,
isFreighter: mapValueOfType<bool>(json, r'isFreighter')!,
verified: mapValueOfType<bool>(json, r'verified')!,
numRegistrations: mapValueOfType<int>(json, r'numRegistrations')!,
serial: mapValueOfType<String>(json, r'serial'),
hexIcao: mapValueOfType<String>(json, r'hexIcao'),
airlineName: mapValueOfType<String>(json, r'airlineName'),
iataType: mapValueOfType<String>(json, r'iataType'),
iataCodeShort: mapValueOfType<String>(json, r'iataCodeShort'),
icaoCode: mapValueOfType<String>(json, r'icaoCode'),
model: mapValueOfType<String>(json, r'model'),
modelCode: mapValueOfType<String>(json, r'modelCode'),
numSeats: mapValueOfType<int>(json, r'numSeats'),
rolloutDate: mapDateTime(json, r'rolloutDate', r''),
firstFlightDate: mapDateTime(json, r'firstFlightDate', r''),
deliveryDate: mapDateTime(json, r'deliveryDate', r''),
registrationDate: mapDateTime(json, r'registrationDate', r''),
typeName: mapValueOfType<String>(json, r'typeName'),
numEngines: mapValueOfType<int>(json, r'numEngines'),
engineType: EngineType.fromJson(json[r'engineType']),
productionLine: mapValueOfType<String>(json, r'productionLine'),
ageYears: mapValueOfType<double>(json, r'ageYears'),
image: AircraftContractImage.fromJson(json[r'image']),
registrations:
AircraftRegistrationContract.listFromJson(json[r'registrations']),
);
}
return null;
}