finished bugs

This commit is contained in:
ashrafzarkanisala
2024-07-27 17:26:44 +03:00
parent 5eee0a2bfd
commit 6a128f9558
6 changed files with 158 additions and 110 deletions

View File

@ -3,8 +3,8 @@ import 'dart:convert';
class ScenesModel {
final String id;
final String name;
final Status status;
final Type type;
final String status;
final String type;
ScenesModel({
required this.id,
@ -20,36 +20,15 @@ class ScenesModel {
factory ScenesModel.fromJson(Map<String, dynamic> json) => ScenesModel(
id: json["id"],
name: json["name"],
status: statusValues.map[json["status"]]!,
type: typeValues.map[json["type"]]!,
name: json["name"] ?? '',
status: json["status"] ?? '',
type: json["type"] ?? '',
);
Map<String, dynamic> toJson() => {
"id": id,
"name": name,
"status": statusValues.reverse[status],
"type": typeValues.reverse[type],
"status": status,
"type": type,
};
}
enum Status { ENABLE }
final statusValues = EnumValues({"enable": Status.ENABLE});
enum Type { TAP_TO_RUN, automation }
final typeValues =
EnumValues({"tap_to_run": Type.TAP_TO_RUN, "automation": Type.automation});
class EnumValues<T> {
Map<String, T> map;
late Map<T, String> reverseMap;
EnumValues(this.map);
Map<T, String> get reverse {
reverseMap = map.map((k, v) => MapEntry(v, k));
return reverseMap;
}
}