fromJson static method

CustomerModel? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static CustomerModel? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    return CustomerModel(
      id: mapValueOfType<int>(json, r'id')!,
      name: mapValueOfType<String>(json, r'name')!,
      image: mapValueOfType<String>(json, r'image')!,
      active: mapValueOfType<bool>(json, r'active')!,
      nif: mapValueOfType<String>(json, r'nif'),
      notes: mapValueOfType<String>(json, r'notes'),
      address: AddressModel.fromJson(json[r'address']),
      contactPerson1: ContactPersonModel.fromJson(json[r'contextPerson1']),
      contactPerson2: ContactPersonModel.fromJson(json[r'contextPerson2']),
      birthDate: mapDateTime(json, r'birthDate', r''),
      lastUpdated: mapDateTime(json, r'lastUpdated', r'')!,
    );
  }
  return null;
}