chooseAirConditionContent_state.dart 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. class ChooseAirConditionContentState{
  2. // totalPrice
  3. get totalPrice {
  4. final prices = checkedServiceList?.map((item) => (item.num ?? 0) * (item.price ?? 0)).toList();
  5. return prices?.isNotEmpty == true ? prices?.reduce((before, current) => before + current) : 0;
  6. }
  7. get checkedServiceList => airConditionList?.where((item) => ((item.num??0)>0? true:false))?.toList() ?? [];
  8. // hasCheckdService
  9. get hasCheckdService => checkedServiceList?.any((item) => ((item.num??0)>0? true:false)) ?? false;
  10. List<AirConditionContentItem> airConditionList = [];
  11. ChooseAirConditionContentState({
  12. required this.airConditionList,
  13. });
  14. ChooseAirConditionContentState copyWith({
  15. List<AirConditionContentItem>? airConditionList,
  16. }){
  17. return ChooseAirConditionContentState(
  18. airConditionList: airConditionList??this.airConditionList,
  19. );
  20. }
  21. }
  22. class AirConditionContentItem{
  23. String? name;
  24. int? id;
  25. int? num;
  26. double? price;
  27. AirConditionContentItem({
  28. this.name,
  29. this.id,
  30. this.num,
  31. this.price
  32. });
  33. AirConditionContentItem copyWith({
  34. String? name,
  35. int? id,
  36. int? num,
  37. double? price
  38. }){
  39. return AirConditionContentItem(
  40. name: name??this.name,
  41. id: id??this.id,
  42. num: num??this.num,
  43. price: price??this.price
  44. );
  45. }
  46. }