mind_map_data.dart 945 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import 'index.dart';
  2. class MindMapData {
  3. final Node root;
  4. final String template;
  5. final String theme;
  6. final String version;
  7. late BaseTheme mapTheme;
  8. late BaseTemplate mapTemplate;
  9. MindMapData(this.root, this.template, this.theme, this.version) {
  10. //处理主题
  11. mapTheme = DarkTheme();
  12. mapTemplate = DefaultTemplate(mapTheme);
  13. }
  14. factory MindMapData.fromJson(Map<String, dynamic> json) {
  15. return MindMapData(
  16. Node.fromJson(json['root']),
  17. json['template'] ?? 'default',
  18. json['theme'] ?? 'fresh-blue',
  19. json['version'] ?? '1.0'
  20. );
  21. }
  22. Map<String, dynamic> _$MindMapToJson(MindMapData instance) {
  23. var map = <String, dynamic>{};
  24. map['root'] = instance.root.toJson();
  25. map['template'] = instance.template;
  26. map['theme'] = instance.theme;
  27. map['version'] = instance.version;
  28. return map;
  29. }
  30. Map<String, dynamic> toJson() => _$MindMapToJson(this);
  31. }