Hi I want a clickable checkbox there are two checkboxes in a row of my code i want them to be clickable
secondly when either one of them is clicked the second one should be disabled automatically.
Here is my code:
Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded(child: CheckboxListTile( title: Text("Yes"), controlAffinity: ListTileControlAffinity.leading, value: null, onChanged: (bool value) { }, ), ), Expanded(child: CheckboxListTile( title: Text("No"),value:false,onChanged:(bool value) {}, controlAffinity: ListTileControlAffinity.leading, ), ) ], ),
I am trying to acheive this but unable to do so any help would be highly appreciated
You should try this
bool firstCheck = false;
bool secondCheck = false;
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expanded(child:
CheckboxListTile(
title: Text("Yes"),
controlAffinity: ListTileControlAffinity.leading, value: firstCheck, onChanged: (bool value) {
setState(() {
firstCheck = value;
secondCheck = !value;
});
},
),
),
Expanded(child:
CheckboxListTile(
title: Text("No"),value:secondCheck,onChanged:(bool value) {
setState(() {
firstCheck = !value;
secondCheck = value;
});
},
controlAffinity: ListTileControlAffinity.leading,
),
)
],
),
You should use radio buttons:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.