import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/model/function_model.dart'; class CurtainModel extends DeviceModel { late int openPercentage; CurtainModel({ required this.openPercentage, required super.id, required super.name, required super.type, required super.status, required super.image, required super.timer, required super.functions, }); Map toJson() { return { 'openPercentage': openPercentage, 'timer': timer, 'id': id, 'name': name, 'status': status, 'type': type, 'image': image, }; } factory CurtainModel.fromJson(Map json) { List func = []; if (json['functions'] != null) { json['functions'].forEach((v) { func.add(FunctionModel.fromJson(v)); }); } return CurtainModel( id: json['id'], name: json['name'], status: json['status'], openPercentage: json['openPercentage'], timer: json['timer'], type: json['type'], image: json['image'], functions: func, ); } }