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.
cloudsolutions-atoms/lib/models/new_models/building.dart

49 lines
985 B
Dart

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