fromJson static method
Returns a new VehicleDetails instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static VehicleDetails? 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(() {
assert(json.containsKey(r'year'),
'Required key "VehicleDetails[year]" is missing from JSON.');
assert(json[r'year'] != null,
'Required key "VehicleDetails[year]" has a null value in JSON.');
assert(json.containsKey(r'make'),
'Required key "VehicleDetails[make]" is missing from JSON.');
assert(json[r'make'] != null,
'Required key "VehicleDetails[make]" has a null value in JSON.');
assert(json.containsKey(r'model'),
'Required key "VehicleDetails[model]" is missing from JSON.');
assert(json[r'model'] != null,
'Required key "VehicleDetails[model]" has a null value in JSON.');
assert(json.containsKey(r'trim'),
'Required key "VehicleDetails[trim]" is missing from JSON.');
assert(json[r'trim'] != null,
'Required key "VehicleDetails[trim]" has a null value in JSON.');
assert(json.containsKey(r'uuid'),
'Required key "VehicleDetails[uuid]" is missing from JSON.');
assert(json[r'uuid'] != null,
'Required key "VehicleDetails[uuid]" has a null value in JSON.');
assert(json.containsKey(r'ucgVehicleId'),
'Required key "VehicleDetails[ucgVehicleId]" is missing from JSON.');
assert(json[r'ucgVehicleId'] != null,
'Required key "VehicleDetails[ucgVehicleId]" has a null value in JSON.');
return true;
}());
return VehicleDetails(
year: mapValueOfType<int>(json, r'year')!,
make: mapValueOfType<String>(json, r'make')!,
model: mapValueOfType<String>(json, r'model')!,
trim: mapValueOfType<String>(json, r'trim')!,
uuid: mapValueOfType<String>(json, r'uuid')!,
ucgVehicleId: mapValueOfType<int>(json, r'ucgVehicleId')!,
);
}
return null;
}