fromJson static method
Returns a new TimeTableItemDto instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static TimeTableItemDto? fromJson(dynamic value) {
if (value is TimeTableItemDto) {
return 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 "TimeTableItemDto[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "TimeTableItemDto[$key]" has a null value in JSON.');
});
return true;
}());
return TimeTableItemDto(
days: json[r'days'] is List ? (json[r'days'] as List).cast<String>() : const [],
hours: TimeTableHourDto.listFromJson(json[r'hours'])!,
recurrenceTypes: json[r'recurrenceTypes'] is List ? (json[r'recurrenceTypes'] as List).cast<String>() : const [],
calendarItemTypeId: mapValueOfType<String>(json, r'calendarItemTypeId'),
homeVisit: mapValueOfType<bool>(json, r'homeVisit')!,
placeId: mapValueOfType<String>(json, r'placeId'),
unavailable: mapValueOfType<bool>(json, r'unavailable')!,
);
}
return null;
}