chooseAirConditionContent_state.dart 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. class ChooseAirConditionContentState{
  2. // 设置一个get totalPrice
  3. get totalPrice => airConditionList.map((item) => (item.num??0) * (item.price??0)).reduce((before, current) => before + current);
  4. List<AirConditionContentItem> airConditionList = [];
  5. ChooseAirConditionContentState({
  6. required this.airConditionList,
  7. });
  8. ChooseAirConditionContentState copyWith({
  9. List<AirConditionContentItem>? airConditionList,
  10. }){
  11. return ChooseAirConditionContentState(
  12. airConditionList: airConditionList??this.airConditionList,
  13. );
  14. }
  15. }
  16. class AirConditionContentItem{
  17. String? name;
  18. int? id;
  19. int? num;
  20. double? price;
  21. AirConditionContentItem({
  22. this.name,
  23. this.id,
  24. this.num,
  25. this.price
  26. });
  27. AirConditionContentItem copyWith({
  28. String? name,
  29. int? id,
  30. int? num,
  31. double? price
  32. }){
  33. return AirConditionContentItem(
  34. name: name??this.name,
  35. id: id??this.id,
  36. num: num??this.num,
  37. price: price??this.price
  38. );
  39. }
  40. }