import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import '../model/ac_company_response_model.dart'; import '../model/ac_mou_response_model.dart'; import '../screen/md_lab_mitra/mitra_lookup_mou_provider.dart'; import '../screen/md_lab_mitra/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 ?? " -- null -- "; if (companyModel != null) { WidgetsBinding.instance.addPostFrameCallback((_) { ref .read(mitraLookupMouProvider.notifier) .lookup(companyID: companyModel.mCompanyID); }); } ref.listen(mitraLookupMouProvider, (prev, next) { if (next is MitraLookupMouStateDone) { 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(minHeight: 50, maxHeight: 200), child: Padding( padding: const EdgeInsets.all(8.0), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Agreement " + companyName, ), SizedBox(height: 10), if (listMou.value.length > 0) Expanded( child: ListView.builder( itemCount: listMou.value.length, itemBuilder: (context, idx) { final model = listMou.value[idx]; return Text(model.mMouName); }), ), ]), ), ), ); } }