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
| Property | Description | Type |
|---|---|---|
value | The currently selected value in the radio group. | T? |
options | A list of C2CRadioOptions to create radio buttons. | List<C2CRadioOptions<T>> |
alignment | The axis along which the radio buttons are aligned. | Axis |
onChanged | Callback when the value of the radio group changes. | Function(T value)? |
verticalSpacing | Vertical spacing between radio buttons. | double |
horizontalSpacing | Horizontal spacing between radio buttons. | double |
error | Error message displayed below the radio group. | String? |
highlightRadio | Whether to highlight the radio button with an error. | bool |
errorTextStyle | Style applied to the error message text. | TextStyle? |
errorTextSpacing | Spacing between the error message and radio buttons. | double? |
descriptionTextStyle | Style applied to the description text. | TextStyle? |
labelSpacingLeft | Left spacing for the label text. | double? |
errorShadow | Shadow applied when there is an error. | BoxShadow? |
labelTextStyle | Style applied to the label text. | TextStyle? |
radioSize | Size of the radio button. | double? |
backgroundColor | Background color of the radio button. | Color? |
borderSide | Border style of the radio button. | BorderSide? |
checkColor | Color of the check mark inside the radio button. | Color? |
activeBackgroundColor | Background color when the radio button is selected. | Color? |
activeBorderSide | Border style when the radio button is selected. | BorderSide? |
disabledCheckColor | Check mark color when the radio button is disabled. | Color? |
disabledBackgroundColor | Background color when the radio button is disabled. | Color? |
disabledBorderSide | Border style when the radio button is disabled. | BorderSide? |
errorCheckColor | Check mark color when there is an error. | Color? |
errorBackgroundColor | Background color when there is an error. | Color? |
errorBorderSide | Border style when there is an error. | BorderSide? |
showErrorMessage | Whether 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
| Property | Description | Type |
|---|---|---|
label | The label displayed next to the radio button. | dynamic |
description | Description text displayed below the label. | dynamic |
value | The value associated with the radio button. | T |
disabled | Whether the radio button is disabled. | bool |