import 'package:test_sa/models/new_models/department.dart'; class Floor { Floor({ this.id, this.name, this.value, this.departments, }); Floor.fromJson(dynamic json) { id = json['id']; name = json['name']; value = json['value']; if (json['departments'] != null) { departments = []; json['departments'].forEach((v) { departments.add(Department.fromJson(v)); }); } } num id; String name; num value; List departments; Floor copyWith({ num id, String name, num value, List departments, }) => Floor( id: id ?? this.id, name: name ?? this.name, value: value ?? this.value, departments: departments ?? this.departments, ); Map toJson() { final map = {}; map['id'] = id; map['name'] = name; map['value'] = value; if (departments != null) { map['departments'] = departments.map((v) => v.toJson()).toList(); } return map; } }