mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 16:41:19 +00:00
43 lines
944 B
Dart
43 lines
944 B
Dart
class TreeNode {
|
|
bool checked;
|
|
bool show;
|
|
int id;
|
|
int pid;
|
|
int commonID;
|
|
String title;
|
|
List<TreeNode> children;
|
|
|
|
TreeNode({
|
|
required this.checked,
|
|
required this.show,
|
|
required this.id,
|
|
required this.pid,
|
|
required this.commonID,
|
|
required this.title,
|
|
required this.children,
|
|
});
|
|
|
|
factory TreeNode.fromJson(Map<String, dynamic> json) {
|
|
return TreeNode(
|
|
checked: json['checked'] ?? false,
|
|
show: json['show'] ?? false,
|
|
id: json['id'] ?? 0,
|
|
pid: json['pid'] ?? 0,
|
|
commonID: json['commonID'] ?? 0,
|
|
title: json['title'] ?? '',
|
|
children: (json['children'] as List<dynamic>)
|
|
.map((childJson) => TreeNode.fromJson(childJson))
|
|
.toList(),
|
|
);
|
|
}
|
|
|
|
List<int> getAllChildrenTitles() {
|
|
List<int> id = [];
|
|
for (var child in children) {
|
|
id.add(child.id);
|
|
id.addAll(child.getAllChildrenTitles());
|
|
}
|
|
return id;
|
|
}
|
|
}
|