66 lines
1.5 KiB
Dart
66 lines
1.5 KiB
Dart
class Floor {
|
|
const Floor({required this.id, required this.name});
|
|
|
|
final int id;
|
|
final String name;
|
|
|
|
factory Floor.fromJson(Map<String, dynamic> json) => Floor(
|
|
id: json['id'] as int,
|
|
name: json['name'] as String,
|
|
);
|
|
}
|
|
|
|
class Room {
|
|
const Room({
|
|
required this.id,
|
|
required this.name,
|
|
required this.floorId,
|
|
required this.x,
|
|
required this.y,
|
|
required this.width,
|
|
required this.height,
|
|
});
|
|
|
|
final int id;
|
|
final String name;
|
|
final int floorId;
|
|
final double x; // offset from floor origin, meters
|
|
final double y;
|
|
final double width; // meters
|
|
final double height; // meters
|
|
|
|
factory Room.fromJson(Map<String, dynamic> json) => Room(
|
|
id: json['id'] as int,
|
|
name: json['name'] as String,
|
|
floorId: json['floor_id'] as int,
|
|
x: ((json['x'] as num?) ?? 0).toDouble(),
|
|
y: (json['y'] as num? ?? 0).toDouble(),
|
|
width: (json['width'] as num).toDouble(),
|
|
height: (json['height'] as num).toDouble(),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'id': id,
|
|
'name': name,
|
|
'floor_id': floorId,
|
|
'x': x,
|
|
'y': y,
|
|
'width': width,
|
|
'height': height,
|
|
};
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
if(other is! Room) {
|
|
return super == other;
|
|
}
|
|
|
|
return other.height == height
|
|
&& other.width == width
|
|
&& other.name == name
|
|
&& other.id == id
|
|
&& other.x == x
|
|
&& other.y == y;
|
|
}
|
|
}
|