fromJson static method

FlowItemDto? fromJson(
  1. dynamic value
)

Returns a new FlowItemDto instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static FlowItemDto? fromJson(dynamic value) {
  if (value is FlowItemDto) {
    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 "FlowItemDto[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "FlowItemDto[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return FlowItemDto(
      id: mapValueOfType<String>(json, r'id'),
      title: mapValueOfType<String>(json, r'title'),
      comment: mapValueOfType<String>(json, r'comment'),
      receptionDate: mapValueOfType<int>(json, r'receptionDate'),
      processingDate: mapValueOfType<int>(json, r'processingDate'),
      processer: mapValueOfType<String>(json, r'processer'),
      cancellationDate: mapValueOfType<int>(json, r'cancellationDate'),
      canceller: mapValueOfType<String>(json, r'canceller'),
      cancellationReason: mapValueOfType<String>(json, r'cancellationReason'),
      cancellationNote: mapValueOfType<String>(json, r'cancellationNote'),
      status: mapValueOfType<String>(json, r'status'),
      homeVisit: mapValueOfType<bool>(json, r'homeVisit'),
      municipality: mapValueOfType<String>(json, r'municipality'),
      town: mapValueOfType<String>(json, r'town'),
      zipCode: mapValueOfType<String>(json, r'zipCode'),
      street: mapValueOfType<String>(json, r'street'),
      building: mapValueOfType<String>(json, r'building'),
      buildingNumber: mapValueOfType<String>(json, r'buildingNumber'),
      doorbellName: mapValueOfType<String>(json, r'doorbellName'),
      floor: mapValueOfType<String>(json, r'floor'),
      letterBox: mapValueOfType<String>(json, r'letterBox'),
      notesOps: mapValueOfType<String>(json, r'notesOps'),
      notesContact: mapValueOfType<String>(json, r'notesContact'),
      latitude: mapValueOfType<String>(json, r'latitude'),
      longitude: mapValueOfType<String>(json, r'longitude'),
      type: mapValueOfType<String>(json, r'type'),
      emergency: mapValueOfType<bool>(json, r'emergency'),
      phoneNumber: mapValueOfType<String>(json, r'phoneNumber'),
      patientId: mapValueOfType<String>(json, r'patientId'),
      patientLastName: mapValueOfType<String>(json, r'patientLastName'),
      patientFirstName: mapValueOfType<String>(json, r'patientFirstName'),
      description: mapValueOfType<String>(json, r'description'),
      interventionCode: mapValueOfType<String>(json, r'interventionCode'),
    );
  }
  return null;
}