sport_target.dart 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import 'package:sport/services/Converter.dart';
  2. class SportTarget {
  3. late int id;
  4. late String name;
  5. String? intension;
  6. int duration = 0;
  7. int consume = 0;
  8. String? fitPeople;
  9. int? sort;
  10. int? userId;
  11. String? type;
  12. int? monthFinish;
  13. int? durationMinute;
  14. SportTarget(
  15. {this.id = 0,
  16. this.name = "",
  17. this.intension,
  18. this.duration = 0,
  19. this.consume = 0,
  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. }