12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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 'chooseAirConditionContent_state.dart';
- part 'chooseAirConditionContent_vm.g.dart';
- List<Map<String, dynamic>> airConditionList = [
- {
- "name": "Hanging air conditioner (unit)",
- "id": 1,
- "price": 40.0,
- },
- {
- "name": "Cabinet air conditioner (unit)",
- "id": 2,
- "price": 50.0,
- },
- {
- "name": "Cylindrical air conditioner (unit)",
- "id": 3,
- "price": 60.0,
- },
- {
- "name": "Central air conditioning (group)",
- "id": 4,
- "price": 70.0,
- },
- ];
- ChooseAirConditionContentState initState(){
- Log.d("--------------------------initState---------------------");
- List<AirConditionContentItem> airConditionListNew = [];
- airConditionList.forEach((item) {
- AirConditionContentItem newItem = AirConditionContentItem()..id = item['id']..price = item['price'] as double..name = item['name']..num = 1;
- airConditionListNew.add(newItem);
- });
- return ChooseAirConditionContentState(
- airConditionList: airConditionListNew,
- );
- }
- @riverpod
- class ChooseAirConditionContentVm extends _$ChooseAirConditionContentVm {
- late ServicesRespository serviceRespositoryInstance;
- @override
- ChooseAirConditionContentState build(){
- // 引入数据仓库
- serviceRespositoryInstance = ref.read(servicesRespositoryProvider);
- ChooseAirConditionContentState state = initState();
- Log.d("--------------------------build---------------------");
- return state;
- }
- handlerChangeNum(BuildContext context, int num, int index){
- state.airConditionList[index].num = num;
- state = state.copyWith(
- airConditionList: state.airConditionList,
- );
- }
- }
|