import 'package:flutter/material.dart'; abstract class DeviceFunction { final String deviceId; final String deviceName; final String code; final String operationName; final String icon; DeviceFunction({ required this.deviceId, required this.deviceName, required this.code, required this.operationName, required this.icon, }); } class DeviceFunctionData { final String entityId; final String actionExecutor; final String functionCode; final String operationName; final dynamic value; final String? condition; final String? valueDescription; final UniqueKey uniqueKey; DeviceFunctionData({ required this.entityId, this.actionExecutor = 'device_issue', required this.functionCode, required this.operationName, required this.value, this.condition, this.valueDescription, }) : uniqueKey = UniqueKey(); Map toJson() { return { 'entityId': entityId, 'actionExecutor': actionExecutor, 'function': functionCode, 'operationName': operationName, 'value': value, if (condition != null) 'condition': condition, if (valueDescription != null) 'valueDescription': valueDescription, }; } factory DeviceFunctionData.fromJson(Map json) { return DeviceFunctionData( entityId: json['entityId'], actionExecutor: json['actionExecutor'] ?? 'function', functionCode: json['function'], operationName: json['operationName'], value: json['value'], condition: json['condition'], valueDescription: json['valueDescription'], ); } @override bool operator ==(Object other) { if (identical(this, other)) return true; return other is DeviceFunctionData && other.entityId == entityId && other.actionExecutor == actionExecutor && other.functionCode == functionCode && other.operationName == operationName && other.value == value && other.condition == condition && other.valueDescription == valueDescription; } @override int get hashCode { return entityId.hashCode ^ actionExecutor.hashCode ^ functionCode.hashCode ^ operationName.hashCode ^ value.hashCode ^ condition.hashCode ^ valueDescription.hashCode; } }