class ChooseHouseCleanContentState{ // 设置一个get totalPrice // 设置一个get totalPrice get totalPrice => HouseCleanList.map((item) => (item.isChecked ?? false) ? (item.num ?? 1) * (item.price ?? 0) : 0).reduce((before, current) => before + current); List HouseCleanList = []; ChooseHouseCleanContentState({ required this.HouseCleanList, }); ChooseHouseCleanContentState copyWith({ List? HouseCleanList, }){ return ChooseHouseCleanContentState( HouseCleanList: HouseCleanList??this.HouseCleanList, ); } } class HouseCleanContentItem{ String? name; String? areaSizeRange; int? id; int? num; double? price; bool? isChecked; bool? isDisable; HouseCleanContentItem({ this.name, this.areaSizeRange, this.id, this.num, this.price, this.isChecked = false, this.isDisable = false, }); HouseCleanContentItem copyWith({ String? name, String? areaSizeRange, int? id, int? num, double? price, bool? isChecked, bool? isDisable, }){ return HouseCleanContentItem( name: name??this.name, areaSizeRange: areaSizeRange??this.areaSizeRange, id: id??this.id, num: num??this.num, price: price??this.price, isChecked: isChecked??this.isChecked, isDisable: isDisable??this.isDisable ); } }