📌  相关文章
📜  未选择颤振问题单选按钮 - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:38.798000             🧑  作者: Mango

代码示例1
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),
  );
}