stats.dart 646 B

123456789101112131415161718192021222324
  1. /// 统计数据模型
  2. class Stats {
  3. final int total;
  4. final Map<String, int> byQuestionType;
  5. final Map<String, int> byImportType;
  6. final Map<String, int> byChapter;
  7. Stats({
  8. this.total = 0,
  9. this.byQuestionType = const {},
  10. this.byImportType = const {},
  11. this.byChapter = const {},
  12. });
  13. factory Stats.fromJson(Map<String, dynamic> json) {
  14. return Stats(
  15. total: json['total'] ?? 0,
  16. byQuestionType: Map<String, int>.from(json['by_question_type'] ?? {}),
  17. byImportType: Map<String, int>.from(json['by_import_type'] ?? {}),
  18. byChapter: Map<String, int>.from(json['by_chapter'] ?? {}),
  19. );
  20. }
  21. }