Radio<T> class
An interactive radio button widget to select a single value from a group.
Interfaces
- Keyboard: When focused is true, pressing Space (
' '), Enter ('\n'), or Carriage Return ('\r') selects value and triggers onChanged. - Mouse: Left-clicking inside bounds selects value and triggers onChanged.
Example Usage
Radio<ThemeMode>(
value: ThemeMode.dark,
groupValue: activeTheme,
label: 'Dark Mode',
onChanged: (ThemeMode val) {
setState(() => activeTheme = val);
},
);
Properties and Styling
| Property | Type | Description |
|---|---|---|
value |
T |
The specific value represented by this radio button. |
groupValue |
T |
The currently selected value of the radio group. |
label |
String | Descriptive label text next to the radio circle. |
onChanged |
Function(T) |
Callback triggered when this option is selected. |
focused |
bool | Whether the widget has keyboard focus. |
style |
Style | Normal rendering style. |
focusedStyle |
Style | Style applied when focused is true. |
Constructors
Properties
- focused → bool
-
Whether the widget has keyboard focus.
final
- focusedStyle → Style
-
The rendering style applied when the radio button is focused.
final
- groupValue → T
-
The currently selected value of the radio group.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isSelected → bool
-
Whether this radio button is currently selected.
no setter
- key → Key?
-
The optional key for this widget.
finalinherited
- label → String
-
The descriptive label text next to the radio circle.
final
- onChanged → void Function(T newValue)
-
The callback triggered when this option is selected.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- style → Style
-
The normal rendering style.
final
- value → T
-
The specific value represented by this radio button.
final
Methods
-
createElement(
) → Element -
Creates an Element to manage this widget's location in the tree.
inherited
-
getIntrinsicHeight(
int width) → int -
Computes the intrinsic height of this widget under the given
widthconstraint.inherited -
handleKeyEvent(
KeyEvent event) → void - Handles key activations (Space or Enter).
-
handleMouseEvent(
MouseEvent event, int localX, int localY) → void - Handles mouse clicks.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
render(
Buffer buffer, Rect area) → void -
Renders the widget onto the provided
bufferwithin the specifiedarea.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited