| 123456789101112131415161718192021222324252627282930 |
- /// 知识点模型
- class KnowledgeNode {
- final String code;
- final String name;
- final List<KnowledgeNode> children;
- final String? fullPath;
- final bool isLeaf;
- KnowledgeNode({
- required this.code,
- required this.name,
- this.children = const [],
- this.fullPath,
- this.isLeaf = false,
- });
- factory KnowledgeNode.fromJson(Map<String, dynamic> json) {
- return KnowledgeNode(
- code: json['code'] ?? '',
- name: json['name'] ?? '',
- children: (json['children'] as List<dynamic>?)
- ?.map((c) => KnowledgeNode.fromJson(c as Map<String, dynamic>))
- .toList() ??
- [],
- fullPath: json['full_path'],
- isLeaf: json['full_path'] != null || (json['children'] == null || (json['children'] as List).isEmpty),
- );
- }
- }
|