import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import '../model/ac_mou_response_model.dart'; import '../screen/md_lab_mitra/mitra_lookup_mou_provider.dart'; import 'fx_data_mitra.dart'; import 'provider/selectedCompanyProvider.dart'; class FxMitraMou extends HookConsumerWidget { final double? width; const FxMitraMou({ Key? key, this.width, }) : super(key: key); @override Widget build(BuildContext context, WidgetRef ref) { final listMou = useState>(List.empty()); final companyModel = ref.watch(selectdAcCompanyProvider); String companyName = companyModel?.mCompanyName ?? ""; ref.listen(mitraLookupMouProvider, (prev, next) { if (next is MitraLookupMouStateDone) { for (int idx = 0; idx < next.list.length; idx++) { next.list[idx].isCheck = false; } listMou.value = next.list; } }); return Container( width: double.infinity, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), border: Border.all(color: Colors.blue.shade700), color: Colors.blue.shade100.withOpacity(0.3), ), child: ConstrainedBox( constraints: BoxConstraints.loose(const Size(double.infinity, 150)), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ FxNormalBlueText( title: "Agreement $companyName", isBold: true, ), const SizedBox(height: 10), if (listMou.value.isNotEmpty) ConstrainedBox( constraints: BoxConstraints.loose(const Size(double.infinity, 100)), child: ListView.builder( shrinkWrap: true, itemCount: listMou.value.length, itemBuilder: (context, idx) { final model = listMou.value[idx]; return Row( children: [ Checkbox( value: model.isCheck, onChanged: ((val) { final List list = List.empty(growable: true); list.addAll(listMou.value); list[idx].isCheck = val ?? false; listMou.value = list; }), ), const SizedBox(width: 10), Expanded( child: FxNormalBlueText(title: model.mMouName), ), ], ); }), ), ]), ), ), ); } }