mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-14 17:25:47 +00:00
38 lines
834 B
Dart
38 lines
834 B
Dart
import 'package:syncrow_app/features/devices/model/room_model.dart';
|
|
import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
|
|
|
class SpaceModel {
|
|
final String? id;
|
|
final String? name;
|
|
final SpaceType type;
|
|
late List<RoomModel>? rooms;
|
|
|
|
SpaceModel({
|
|
required this.type,
|
|
required this.id,
|
|
required this.name,
|
|
required this.rooms,
|
|
});
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'id': id,
|
|
'name': name,
|
|
'rooms': rooms,
|
|
};
|
|
}
|
|
|
|
factory SpaceModel.fromJson(Map<String, dynamic> json) {
|
|
return SpaceModel(
|
|
id: json['uuid'],
|
|
name: json['name'],
|
|
type: spaceTypesMap[json['type']]!,
|
|
rooms: [],
|
|
);
|
|
}
|
|
|
|
static List<SpaceModel> fromJsonList(List<dynamic> jsonList) {
|
|
return jsonList.map((item) => SpaceModel.fromJson(item)).toList();
|
|
}
|
|
}
|