chooseHouseCleanContent_state.dart 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. class ChooseHouseCleanContentState{
  2. // 设置一个get totalPrice
  3. // 设置一个get totalPrice
  4. get totalPrice => HouseCleanList.map((item) => (item.isChecked ?? false) ? (item.num ?? 1) * (item.price ?? 0) : 0).reduce((before, current) => before + current);
  5. List<HouseCleanContentItem> HouseCleanList = [];
  6. ChooseHouseCleanContentState({
  7. required this.HouseCleanList,
  8. });
  9. ChooseHouseCleanContentState copyWith({
  10. List<HouseCleanContentItem>? HouseCleanList,
  11. }){
  12. return ChooseHouseCleanContentState(
  13. HouseCleanList: HouseCleanList??this.HouseCleanList,
  14. );
  15. }
  16. }
  17. class HouseCleanContentItem{
  18. String? name;
  19. String? areaSizeRange;
  20. int? id;
  21. int? num;
  22. double? price;
  23. bool? isChecked;
  24. bool? isDisable;
  25. HouseCleanContentItem({
  26. this.name,
  27. this.areaSizeRange,
  28. this.id,
  29. this.num,
  30. this.price,
  31. this.isChecked = false,
  32. this.isDisable = false,
  33. });
  34. HouseCleanContentItem copyWith({
  35. String? name,
  36. String? areaSizeRange,
  37. int? id,
  38. int? num,
  39. double? price,
  40. bool? isChecked,
  41. bool? isDisable,
  42. }){
  43. return HouseCleanContentItem(
  44. name: name??this.name,
  45. areaSizeRange: areaSizeRange??this.areaSizeRange,
  46. id: id??this.id,
  47. num: num??this.num,
  48. price: price??this.price,
  49. isChecked: isChecked??this.isChecked,
  50. isDisable: isDisable??this.isDisable
  51. );
  52. }
  53. }