Answers for "flutter issue radio button not selected"

0

flutter issue radio button not selected

int _groupValue = -1;

@override
Widget build(BuildContext context) {
  return Column(
    children: <Widget>[
      _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),
  );
}
Posted by: Guest on August-05-2021

Browse Popular Code Answers by Language