import 'package:test_sa/models/base.dart'; import 'package:test_sa/models/new_models/department.dart'; class Floor extends Base { Floor({ this.id, String name, this.value, this.departments, }) : super(identifier: id.toString(), name: name); Floor.fromJson(dynamic json) { id = json['id']; identifier = id.toString(); name = json['name']; value = json['value']; if (json['departments'] != null) { departments = []; json['departments'].forEach((v) { departments.add(Department.fromJson(v)); }); } } num id; 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({bool addDepartments = true}) { final map = {}; map['id'] = id; map['name'] = name; map['value'] = value; if (addDepartments) if (departments != null) { map['departments'] = departments.map((v) => v.toJson()).toList(); } return map; } }