fromJson static method
Returns a new Attendee instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static Attendee? 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'email'), 'Required key "Attendee[email]" is missing from JSON.');
assert(json[r'email'] != null, 'Required key "Attendee[email]" has a null value in JSON.');
assert(json.containsKey(r'status'), 'Required key "Attendee[status]" is missing from JSON.');
assert(json[r'status'] != null, 'Required key "Attendee[status]" has a null value in JSON.');
assert(json.containsKey(r'role'), 'Required key "Attendee[role]" is missing from JSON.');
assert(json[r'role'] != null, 'Required key "Attendee[role]" has a null value in JSON.');
assert(json.containsKey(r'optional'), 'Required key "Attendee[optional]" is missing from JSON.');
assert(json[r'optional'] != null, 'Required key "Attendee[optional]" has a null value in JSON.');
return true;
}());
return Attendee(
email: mapValueOfType<String>(json, r'email')!,
name: mapValueOfType<String>(json, r'name'),
status: AttendeeStatus.fromJson(json[r'status'])!,
role: AttendeeRole.fromJson(json[r'role'])!,
optional: mapValueOfType<bool>(json, r'optional')!,
comment: mapValueOfType<String>(json, r'comment'),
additionalGuests: mapValueOfType<int>(json, r'additional_guests'),
);
}
return null;
}