class ChooseAirConditionContentState{ // 设置一个get totalPrice get totalPrice => airConditionList.map((item) => (item.num??0) * (item.price??0)).reduce((before, current) => before + current); List airConditionList = []; ChooseAirConditionContentState({ required this.airConditionList, }); ChooseAirConditionContentState copyWith({ List? airConditionList, }){ return ChooseAirConditionContentState( airConditionList: airConditionList??this.airConditionList, ); } } class AirConditionContentItem{ String? name; int? id; int? num; double? price; AirConditionContentItem({ this.name, this.id, this.num, this.price }); AirConditionContentItem copyWith({ String? name, int? id, int? num, double? price }){ return AirConditionContentItem( name: name??this.name, id: id??this.id, num: num??this.num, price: price??this.price ); } }