I'm using bloc architecture for my project, and I'm trying to disable/enable the form based upon the checkbox value.
Here is my code->>>
Widget _buildSameAsResidential(BuildContext context) {
return StreamBuilder<FormValue<bool, String>>(
initialData: _addressBloc.residentailEqualMailingValue,
stream: _addressBloc.residentailEqualMailing,
builder: (context, snapshot) {
return MemberFormField(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Checkbox(
onChanged: (isChecked) {
setState(() {
_isBothAddressEquals = isChecked;
});
_addressBloc.dispatch(
UpdateResidentialEqualMailing(value: isChecked));
},
value: snapshot.data.value,
),
],
),
);
},
);
}
There is no crime in using setState together with bloc if the need arises, but for the way use are using it in your code, setState is not needed. The checkbox state has been handled by the block.