sport_target_index.dart 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import 'package:sport/bean/sport_target_day.dart';
  2. import 'package:sport/bean/sport_target_record.dart';
  3. import 'sport_target.dart';
  4. class SportTargetIndex {
  5. SportTarget target;
  6. SportTargetDay today;
  7. List<SportTargetRecord> records;
  8. List<Rewards> rewards;
  9. SportTargetIndex({this.target, this.today, this.records, this.rewards});
  10. SportTargetIndex.fromJson(Map<String, dynamic> json) {
  11. target =
  12. json['target'] != null ? new SportTarget.fromJson(json['target']) : null;
  13. today = json['today'] != null ? new SportTargetDay.fromJson(json['today']) : null;
  14. if (json['records'] != null) {
  15. records = new List<SportTargetRecord>();
  16. json['records'].forEach((v) {
  17. records.add(new SportTargetRecord.fromJson(v));
  18. });
  19. }
  20. if (json['rewards'] != null) {
  21. rewards = new List<Rewards>();
  22. json['rewards'].forEach((v) {
  23. rewards.add(new Rewards.fromJson(v));
  24. });
  25. }
  26. }
  27. Map<String, dynamic> toJson() {
  28. final Map<String, dynamic> data = new Map<String, dynamic>();
  29. if (this.target != null) {
  30. data['target'] = this.target.toJson();
  31. }
  32. if (this.today != null) {
  33. data['today'] = this.today.toJson();
  34. }
  35. if (this.records != null) {
  36. data['records'] = this.records.map((v) => v.toJson()).toList();
  37. }
  38. if (this.rewards != null) {
  39. data['rewards'] = this.rewards.map((v) => v.toJson()).toList();
  40. }
  41. return data;
  42. }
  43. }
  44. class Rewards {
  45. int id;
  46. int fullMonth;
  47. int score;
  48. String status;
  49. int days;
  50. Rewards({this.id, this.fullMonth, this.score, this.status, this.days});
  51. Rewards.fromJson(Map<String, dynamic> json) {
  52. id = json['id'];
  53. fullMonth = json['full_month'];
  54. score = json['score'];
  55. status = json['status'];
  56. days = json['days'];
  57. }
  58. Map<String, dynamic> toJson() {
  59. final Map<String, dynamic> data = new Map<String, dynamic>();
  60. data['id'] = this.id;
  61. data['full_month'] = this.fullMonth;
  62. data['score'] = this.score;
  63. data['status'] = this.status;
  64. data['days'] = this.days;
  65. return data;
  66. }
  67. }