Files
syncrow-app/lib/features/app_layout/model/space_model.dart
Mohammad Salameh 13e80fbad7 fetch groups
2024-03-18 11:46:27 +03:00

34 lines
690 B
Dart

import 'package:syncrow_app/features/devices/model/room_model.dart';
class SpaceModel {
final int? id;
final String? name;
late List<RoomModel>? rooms;
SpaceModel({
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: int.parse(json['homeId']),
name: json['homeName'],
rooms: [],
);
}
static List<SpaceModel> fromJsonList(List<dynamic> jsonList) {
return jsonList.map((item) => SpaceModel.fromJson(item)).toList();
}
}