import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/utils/resource_manager/constants.dart'; class RoomModel { final String? id; final String? name; final SpaceType type; List? devices; RoomModel({ required this.id, required this.name, required this.type, required this.devices, }); Map toJson() { return { 'id': id, 'name': name, 'type': type, 'devices': devices, }; } factory RoomModel.fromJson(Map json) { List devices = []; if (json['devices'] != null) { for (var device in json['devices']) { devices.add(DeviceModel.fromJson(device)); } } return RoomModel( id: json['uuid'], name: json['name'], type: spaceTypesMap[json['type']]!, devices: [], ); } }