Enhance SkillTreeNode Model to Include Additional Attributes

This commit extends the SkillTreeNode class to incorporate new attributes such as 'data', 'label', and 'shape', making the model more comprehensive. The JSON deserialization is also updated to handle optional or missing fields by providing default values, improving the robustness of the model.
pull/5213/head^2
hunteraraujo 2023-09-13 17:32:23 -07:00
parent 774ccc4ed2
commit 30934f400a
1 changed files with 16 additions and 7 deletions

View File

@ -1,18 +1,27 @@
import 'package:auto_gpt_flutter_client/models/skill_tree/skill_node_data.dart';
// TODO: Update this with actual data
class SkillTreeNode {
final String color;
final int id;
final SkillNodeData data;
final String id;
final String label;
final String shape;
// final SkillNodeData data;
SkillTreeNode({required this.color, required this.id});
SkillTreeNode({
required this.color,
required this.data,
required this.id,
required this.label,
required this.shape,
});
factory SkillTreeNode.fromJson(Map<String, dynamic> json) {
return SkillTreeNode(
color: json['color'],
id: json['id'],
color: json['color'] ?? "",
data: SkillNodeData.fromJson(json['data'] ?? {}),
id: json['id'] ?? "",
label: json['label'] ?? "",
shape: json['shape'] ?? "",
);
}
}