📅  最后修改于: 2022-03-11 14:58:38.798000             🧑  作者: Mango
int _groupValue = -1;
@override
Widget build(BuildContext context) {
return Column(
children: [
_myRadioButton(
title: "Checkbox 0",
value: 0,
onChanged: (newValue) => setState(() => _groupValue = newValue),
),
_myRadioButton(
title: "Checkbox 1",
value: 1,
onChanged: (newValue) => setState(() => _groupValue = newValue),
),
],
);
}
Widget _myRadioButton({String title, int value, Function onChanged}) {
return RadioListTile(
value: value,
groupValue: _groupValue,
onChanged: onChanged,
title: Text(title),
);
}