sport_target.dart 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import 'package:sport/services/Converter.dart';
  2. class SportTarget {
  3. int id;
  4. String name;
  5. String intension;
  6. int duration;
  7. int consume;
  8. String fitPeople;
  9. int sort;
  10. int userId;
  11. String type;
  12. int monthFinish;
  13. int durationMinute;
  14. SportTarget(
  15. {this.id,
  16. this.name,
  17. this.intension,
  18. this.duration,
  19. this.consume,
  20. this.fitPeople,
  21. this.sort,
  22. this.userId});
  23. SportTarget.fromJson(Map<String, dynamic> json) {
  24. id = json['id'];
  25. name = json['name'];
  26. intension = json['intension'];
  27. duration = json['duration'];
  28. consume = json['consume'];
  29. fitPeople = json['fit_people'];
  30. sort = json['sort'];
  31. userId = Converter.toInt(json['user_id']);
  32. type = json['type'];
  33. monthFinish = json['month_finish'];
  34. durationMinute = json['duration_minute'];
  35. }
  36. Map<String, dynamic> toJson() {
  37. final Map<String, dynamic> data = new Map<String, dynamic>();
  38. data['id'] = this.id;
  39. data['name'] = this.name;
  40. data['intension'] = this.intension;
  41. data['duration'] = this.duration;
  42. data['consume'] = this.consume;
  43. data['fit_people'] = this.fitPeople;
  44. data['sort'] = this.sort;
  45. data['user_id'] = this.userId;
  46. data['type'] = this.type;
  47. data['month_finish'] = this.monthFinish;
  48. data['duration_minute'] = this.durationMinute;
  49. return data;
  50. }
  51. int get valueTarget => type == "consume" ? consume : durationMinute;
  52. String get label => type == "consume" ? "卡" : "分钟";
  53. }