_updatePersonalFormScreen(String loginId) async {
if (!DartUtility.isNullEmptyOrWhitespace(loginId)) {
_personalInfo = await _service.getUserPersonalDetails(loginId);
setState(() {
if (_personalInfo != null) {
if(!DartUtility.isNullEmptyList(_personalInfo.getContacts())){
contactList = _personalInfo.getContacts();
}
personalInfoMap = _personalInfo.toPersonalInfoMap();
}
print('personalInfo retrieved object ${_personalInfo.toString()}'); //1
});
}
}
formBuilder widget :
FormBuilder buildFormBuilder(BuildContext context) {
print('personalInfoMap $personalInfoMap'); //2
return FormBuilder(
key: _personalDetailFormKey,
initialValue: personalInfoMap, //3
autovalidate: true,
child: Stack(),
);
}
//line-1 and line-2 printing correct values but at line-3, the initial values are not getting assigned to the form builder textbox
'contactList' is populating correctly and in the same block populating 'personalInfoMap' not working properly as expected or may value assigned at line-3 need some thing else to be modified to make it work
I have tried working with Future builder as well but no luck. If 'contactList' is working fine and assigned to the form values, so why facing issue in other field ? :(
Could someone please help me on this, What else need to be done here and where its getting wrong.
After 4 5 hour struggle, able to resolved finally, and the saviour is 'Future builder'. here is the solution,
Instead of directly calling FormBuilder in build method, wrap it inside FutureBuilder
Modified formBuilder widget :