chooseVisitTimeContent_state.dart 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import 'package:widgets/load_state_layout.dart';
  2. import 'visitTimeType.dart';
  3. class ChooseVisitTimeContentState{
  4. // 设置一个get totalPrice
  5. get totalPrice => visitTimeList.map((item) => (item.isChecked??false) ? item.price??0 : 0 ).reduce((before, current) => before + current);
  6. //页面 LoadView 状态的展示
  7. LoadState loadingState;
  8. String? errorMessage;
  9. List<VisitTimeContentItem> visitTimeList = [];
  10. ChooseVisitTimeContentState({
  11. this.loadingState = LoadState.State_Loading,
  12. this.errorMessage,
  13. required this.visitTimeList,
  14. });
  15. ChooseVisitTimeContentState copyWith({
  16. LoadState? loadingState,
  17. String? errorMessage,
  18. List<VisitTimeContentItem>? visitTimeList,
  19. }){
  20. return ChooseVisitTimeContentState(
  21. loadingState: loadingState??this.loadingState,
  22. errorMessage: errorMessage??this.errorMessage,
  23. visitTimeList: visitTimeList??this.visitTimeList,
  24. );
  25. }
  26. }
  27. class VisitTimeContentItem{
  28. String? name;
  29. int? id;
  30. double? price;
  31. Map<String, dynamic>? type;
  32. bool? isChecked;
  33. bool? isDisable;
  34. VisitTimeContentItem({
  35. this.name,
  36. this.id,
  37. this.price,
  38. this.type,
  39. this.isChecked = false,
  40. this.isDisable = false,
  41. });
  42. VisitTimeContentItem copyWith({
  43. String? name,
  44. int? id,
  45. double? price,
  46. Map<String, dynamic>? type,
  47. bool? isChecked,
  48. bool? isDisable,
  49. }){
  50. return VisitTimeContentItem(
  51. name: name??this.name,
  52. id: id??this.id,
  53. price: price??this.price,
  54. type: type ?? this.type, // 在这里设置默认值
  55. isChecked: isChecked??this.isChecked,
  56. isDisable: isDisable??this.isDisable,
  57. );
  58. }
  59. }