import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:riverpod_annotation/riverpod_annotation.dart'; import 'package:router/ext/auto_router_extensions.dart'; import 'package:shared/utils/log_utils.dart'; import 'package:widgets/dialog/dialog_content_wrap.dart'; import '../../../respository/services_respository.dart'; import 'chooseHouseCleanContent_state.dart'; part 'chooseHouseCleanContent_vm.g.dart'; List> HouseCleanList = [ { "name": "House Clean 1(unit)", "id": 1, "price": 40.0, "num":1, "areaSizeRange": "≤600 sqft", "isChecked": false, "isDisable": false, }, { "name": "House Clean 2(unit)", "id": 2, "price": 57.0, "num":1, "areaSizeRange": "601-800 sqft", "isChecked": false, "isDisable": false, }, { "name": "House Clean 3(unit)", "id": 3, "price": 72.0, "num":1, "areaSizeRange": "801-1000 sqft", "isChecked": false, "isDisable": false, }, { "name": "House Clean 3(unit)", "id": 4, "price": 85.0, "num":1, "areaSizeRange": "1001-1200 sqft", "isChecked": false, "isDisable": false, }, ]; @riverpod class ChooseHouseCleanContentVm extends _$ChooseHouseCleanContentVm { late ServicesRespository serviceRespositoryInstance; late BuildContext _context; late Map? _initProps; ChooseHouseCleanContentState initState(){ Log.d("--------------------------initState---------------------"); List HouseCleanListNew = []; HouseCleanList.forEach((item) { HouseCleanContentItem newItem = HouseCleanContentItem() ..id = item['id'] ..price = item['price'] as double ..name = item['name'] ..num = 1 ..areaSizeRange = item['areaSizeRange'] ..isChecked = item['isChecked'] ..isDisable = item['isDisable']; HouseCleanListNew.add(newItem); }); return ChooseHouseCleanContentState( HouseCleanList: HouseCleanListNew, ); } @override ChooseHouseCleanContentState build(){ // 引入数据仓库 serviceRespositoryInstance = ref.read(servicesRespositoryProvider); ChooseHouseCleanContentState state = initState(); Log.d("--------------------------build---------------------"); return state; } setInitPageData(BuildContext context, Map? params){ _context = context; Log.d("--------------------------setInitPageData----------$params-----------"); _initProps = params; } handlerChangeNum(BuildContext context, bool isChecked, int index){ state.HouseCleanList[index].isChecked = isChecked; state = state.copyWith( HouseCleanList: state.HouseCleanList, ); } }