import 'dart:convert'; import 'package:flutter/foundation.dart'; class SceneStaticFunction { final String icon; final String name; final String code; final List operationalValues; SceneStaticFunction({ required this.icon, required this.name, required this.code, required this.operationalValues, }); SceneStaticFunction copyWith({ String? icon, String? name, String? code, List? operationalValues, }) { return SceneStaticFunction( icon: icon ?? this.icon, name: name ?? this.name, code: code ?? this.code, operationalValues: operationalValues ?? this.operationalValues, ); } Map toMap() { return { 'icon': icon, 'name': name, 'code': code, 'operationalValues': operationalValues.map((x) => x.toMap()).toList(), }; } factory SceneStaticFunction.fromMap(Map map) { return SceneStaticFunction( icon: map['icon'] ?? '', name: map['name'] ?? '', code: map['code'] ?? '', operationalValues: List.from( map['operationalValues'] ?.map((x) => StaticFunctionOperationHelper.fromMap(x))), ); } String toJson() => json.encode(toMap()); factory SceneStaticFunction.fromJson(String source) => SceneStaticFunction.fromMap(json.decode(source)); @override String toString() { return 'SceneStaticFunction(icon: $icon, name: $name, code: $code, operationalValues: $operationalValues)'; } @override bool operator ==(Object other) { if (identical(this, other)) return true; return other is SceneStaticFunction && other.icon == icon && other.name == name && other.code == code && listEquals(other.operationalValues, operationalValues); } @override int get hashCode { return icon.hashCode ^ name.hashCode ^ code.hashCode ^ operationalValues.hashCode; } } class StaticFunctionOperationHelper { final String icon; final String value; StaticFunctionOperationHelper({ required this.icon, required this.value, }); StaticFunctionOperationHelper copyWith({ String? icon, String? value, }) { return StaticFunctionOperationHelper( icon: icon ?? this.icon, value: value ?? this.value, ); } Map toMap() { return { 'icon': icon, 'value': value, }; } factory StaticFunctionOperationHelper.fromMap(Map map) { return StaticFunctionOperationHelper( icon: map['icon'] ?? '', value: map['value'] ?? '', ); } String toJson() => json.encode(toMap()); factory StaticFunctionOperationHelper.fromJson(String source) => StaticFunctionOperationHelper.fromMap(json.decode(source)); @override String toString() => 'StaticFunctionOperationHelper(icon: $icon, value: $value)'; @override bool operator ==(Object other) { if (identical(this, other)) return true; return other is StaticFunctionOperationHelper && other.icon == icon && other.value == value; } @override int get hashCode => icon.hashCode ^ value.hashCode; }