You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.2 KiB
Dart
53 lines
1.2 KiB
Dart
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<Department> departments;
|
|
|
|
Floor copyWith({
|
|
num id,
|
|
String name,
|
|
num value,
|
|
List<Department> departments,
|
|
}) =>
|
|
Floor(
|
|
id: id ?? this.id,
|
|
name: name ?? this.name,
|
|
value: value ?? this.value,
|
|
departments: departments ?? this.departments,
|
|
);
|
|
|
|
Map<String, dynamic> toJson({bool addDepartments = true}) {
|
|
final map = <String, dynamic>{};
|
|
map['id'] = id;
|
|
map['name'] = name;
|
|
map['value'] = value;
|
|
if (addDepartments) if (departments != null) {
|
|
map['departments'] = departments.map((v) => v.toJson()).toList();
|
|
}
|
|
return map;
|
|
}
|
|
}
|