A package to create simple radio buttons.
Render a radio button group:
- with any number of buttons
- vertical or horizontal
- square or round
Currently only supports String as value and button label. An option for RadioGroup is passed via class RadioOption.
To use this plugin, add crea_radio_button as a dependency in your pubspec.yaml file.
String radioButtonInput = "";
RadioButtonGroup(
buttonHeight: 35,
buttonWidth: 60,
circular: true,
mainColor: Colors.grey,
selectedColor: Colors.pink.shade400,
preSelectedIdx: defaultOptionIndex,
options: [
RadioOption("10.0", "10"),
RadioOption("25.0", "25"),
RadioOption("50.0", "50"),
RadioOption("100.0", "100")
],
callback: (RadioOption val) {
setState(() {
selectedOption = val;
});
})
By default none of the options is preselected. You can specify index of the option you want to be preselected/
defaultIdx: 0
By default there is no Border on a button. `selectedBorderSide can be used to add border for the selected option.
Callback function returns the selected RadioOption
String radioButtonInput = "";
RadioButtonGroup(
vertical: true,
options: [
RadioOption("1", "1"),
RadioOption("2", "2"),
RadioOption("3", "3")
],
buttonHeight: 50,
buttonWidth: 50,
defaultIdx: defaultRadioIdx,
callback: (val) {
setState(() {
radioButtonInput = val.text;
});
});
Contribute here: https://github.com/dutkaD/crea_radio