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