Skip to main content

Radio Group

C2CRadioGroup is a widget for creating a group of radio buttons in Flutter. This widget is useful for presenting a set of mutually exclusive options. It is highly customizable, allowing various styles and configurations to be applied to the radio buttons.

Installation

cpub add c2c_radio

or

flutter pub add c2c_radio --hosted-url=https://pub.csp.scrum-dev.com

Example

C2CRadioGroup<String>(
options: [
C2CRadioOptions(value: 'Option1', label: 'Option 1'),
C2CRadioOptions(value: 'Option2', label: 'Option 2', disabled: true),
],
value: 'Option1',
onChanged: (value) {
// Handle radio value change
},
// Additional customizations
);

Properties

PropertyDescriptionType
valueThe currently selected value in the radio group.T?
optionsA list of C2CRadioOptions to create radio buttons.List<C2CRadioOptions<T>>
alignmentThe axis along which the radio buttons are aligned.Axis
onChangedCallback when the value of the radio group changes.Function(T value)?
verticalSpacingVertical spacing between radio buttons.double
horizontalSpacingHorizontal spacing between radio buttons.double
errorError message displayed below the radio group.String?
highlightRadioWhether to highlight the radio button with an error.bool
errorTextStyleStyle applied to the error message text.TextStyle?
errorTextSpacingSpacing between the error message and radio buttons.double?
descriptionTextStyleStyle applied to the description text.TextStyle?
labelSpacingLeftLeft spacing for the label text.double?
errorShadowShadow applied when there is an error.BoxShadow?
labelTextStyleStyle applied to the label text.TextStyle?
radioSizeSize of the radio button.double?
backgroundColorBackground color of the radio button.Color?
borderSideBorder style of the radio button.BorderSide?
checkColorColor of the check mark inside the radio button.Color?
activeBackgroundColorBackground color when the radio button is selected.Color?
activeBorderSideBorder style when the radio button is selected.BorderSide?
disabledCheckColorCheck mark color when the radio button is disabled.Color?
disabledBackgroundColorBackground color when the radio button is disabled.Color?
disabledBorderSideBorder style when the radio button is disabled.BorderSide?
errorCheckColorCheck mark color when there is an error.Color?
errorBackgroundColorBackground color when there is an error.Color?
errorBorderSideBorder style when there is an error.BorderSide?
showErrorMessageWhether to show the error message.bool

C2CRadioOptions

Overview

C2CRadioOptions defines individual options within a C2CRadioGroup. Each option represents a single radio button with its own properties.

Properties

PropertyDescriptionType
labelThe label displayed next to the radio button.dynamic
descriptionDescription text displayed below the label.dynamic
valueThe value associated with the radio button.T
disabledWhether the radio button is disabled.bool