123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- class ChooseHouseCleanContentState{
- // totalPrice
- get totalPrice => houseCleanList?.map((item) => (item.isChecked ?? false) ? (item.num ?? 1) * (item.price ?? 0) : 0).reduce((before, current) => before + current)?? 0;
- // hasCheckdService
- get hasCheckdService => houseCleanList?.any((item) => (item.isChecked ?? false)) ?? false;
- // 选取的服务项目
- get checkedServiceList => houseCleanList?.where((item) => (item.isChecked ?? false))?.toList() ?? [];
- List<HouseCleanContentItem>? houseCleanList;
- ChooseHouseCleanContentState({
- required this.houseCleanList,
- });
- ChooseHouseCleanContentState copyWith({
- List<HouseCleanContentItem>? 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
- );
- }
- }
|