chooseHouseCleanContent_state.dart 1.6 KB

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