Skip to content

dutkaD/crea_radio

Repository files navigation

CreaRadioButton - an easy radio button group

A package to create simple radio buttons.

Example

Change border on slected

alt text

Change background color on selected

alt text

Unselect is enabled

alt text

Features

Render a radio button group:

  • with any number of buttons
  • vertical or horizontal
  • square or round

Limitations

Currently only supports String as value and button label. An option for RadioGroup is passed via class RadioOption.

Getting started

To use this plugin, add crea_radio_button as a dependency in your pubspec.yaml file.

RadioButtonGroup

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;
                  });
                })

Default selection

By default none of the options is preselected. You can specify index of the option you want to be preselected/ defaultIdx: 0

Add Border for seleted option

By default there is no Border on a button. `selectedBorderSide can be used to add border for the selected option.

Callback

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;
                        });
                      });

Additional information

Contribute here: https://github.com/dutkaD/crea_radio

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages