I want to disable "are you pregnant" checkbox if I choose (gender)radio button as "male" in previous page named as Registration page. I used routes argument in main class to navigate through pages.
//Radio button ListTile(
title: const Text('Male'),
leading: Radio<Gender>(
value: Gender.Male,
groupValue: _gender,
onChanged: (Gender? value) {
setState(() {
var isMale = false;
_gender = value;
if (_gender == Gender.Male){
isMale= true;
CheckUpPage(gender: isMale);
}
});
},
),
),
i am using enum class named Gender for radio button value argument. CheckBoxState.checkUpTitleList[0] = 'are you pregnant'
Widget buildSingleCheckBox(CheckBoxState checkBox) => CheckboxListTile(
controlAffinity: ListTileControlAffinity.leading,
activeColor: Theme.of(context).primaryColor,
value: checkBox.value,
title: Container(
width: 300,
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 4),
child: Text(
checkBox.title,
softWrap: true,
overflow: TextOverflow.fade,
),
),
onChanged: (checkBox.title == CheckBoxState.checkUpTitleList[0] && widget.gender == true)? null: (val){
setState(() {
checkBox.value =val!;
});
},
);
I tried to do it this way but didn't worked.
Aucun commentaire:
Enregistrer un commentaire