push functions static data

This commit is contained in:
ashrafzarkanisala
2024-06-26 02:18:15 +03:00
parent 6413d2b876
commit 3ddd4ed197
34 changed files with 1044 additions and 120 deletions

View File

@ -0,0 +1,135 @@
import 'dart:convert';
import 'package:flutter/foundation.dart';
class SceneStaticFunction {
final String icon;
final String name;
final String code;
final List<StaticFunctionOperationHelper> operationalValues;
SceneStaticFunction({
required this.icon,
required this.name,
required this.code,
required this.operationalValues,
});
SceneStaticFunction copyWith({
String? icon,
String? name,
String? code,
List<StaticFunctionOperationHelper>? operationalValues,
}) {
return SceneStaticFunction(
icon: icon ?? this.icon,
name: name ?? this.name,
code: code ?? this.code,
operationalValues: operationalValues ?? this.operationalValues,
);
}
Map<String, dynamic> toMap() {
return {
'icon': icon,
'name': name,
'code': code,
'operationalValues': operationalValues.map((x) => x.toMap()).toList(),
};
}
factory SceneStaticFunction.fromMap(Map<String, dynamic> map) {
return SceneStaticFunction(
icon: map['icon'] ?? '',
name: map['name'] ?? '',
code: map['code'] ?? '',
operationalValues: List<StaticFunctionOperationHelper>.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<String, dynamic> toMap() {
return {
'icon': icon,
'value': value,
};
}
factory StaticFunctionOperationHelper.fromMap(Map<String, dynamic> 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;
}