Skip to main content

RadioGroup

A collection of selectable options rendered as a radio group.

When to use it

Use RadioGroup<T> whenever a screen needs a mutually-exclusive set of options — settings pickers, plan selectors, or survey questions. RadioGroup has no default (unnamed) constructor; pick one of its named constructors based on the desired visual layout: simple lists, lists with descriptions, tables, panels, or cards.

Import

import 'package:catalyst_ui/catalyst_ui.dart';

Usage

RadioGroup<String>.simpleList(
title: const Text('Notification frequency'),
value: _frequency,
onOptionSelected: (v) => setState(() => _frequency = v),
options: const [
RadioGroupOption(value: 'daily', label: Text('Daily')),
RadioGroupOption(value: 'weekly', label: Text('Weekly')),
],
)

Parameters

RadioGroup<T> is generic over the option value type T. All constructors share these parameters:

ParameterTypeDefaultDescription
titleWidget?nullAn optional title. Typically a Text.
subtitleWidget?nullAn optional subtitle. Typically a Text. Asserts if set without a title.
valueT?nullThe currently selected value.
onOptionSelectedValueChanged<T?>?nullCalled when an option is selected.

RadioGroup.simpleList

A simple vertical list of options.

ParameterTypeDefaultDescription
optionsList<RadioGroupOption<T>>requiredThe options to display.
inlineboolfalseWhen true, displays options in a horizontal wrap layout instead of a vertical list.

RadioGroup.simpleListWithTrailingRadio

A simple vertical list of options with the radio indicator on the right. Takes options (required).

RadioGroup.listWithDescription

A vertical list of options with descriptions.

ParameterTypeDefaultDescription
optionsList<RadioGroupOption<T>>requiredThe options to display.
inlineDescriptionboolfalseWhen true, displays the description alongside the label instead of below it.

RadioGroup.listWithTrailingRadio

A vertical list of options with descriptions and the radio indicator on the right. Takes options (required); dividers are shown between rows.

RadioGroup.table

Options displayed in a bordered table with multiple columns per row. Takes tableOptions: List<RadioGroupTableOption<T>> (required).

RadioGroup.panel

Options displayed in a bordered panel. Takes options (required).

RadioGroup.cards

Options displayed as cards.

ParameterTypeDefaultDescription
cardOptionsList<RadioGroupCardOption<T>>requiredThe card options to display.
stackedboolfalseWhen true, displays cards in a vertical column instead of a horizontal wrap.

RadioGroupOption<T>

Used by simpleList, simpleListWithTrailingRadio, listWithDescription, listWithTrailingRadio, and panel.

ParameterTypeDefaultDescription
valueTrequiredThe value represented by this option.
labelWidgetrequiredThe primary label. Typically a Text widget.
descriptionWidget?nullAn optional description. Typically a Text widget.

RadioGroupTableOption<T>

Used by RadioGroup.table.

ParameterTypeDefaultDescription
valueTrequiredThe value represented by this option.
columnsList<Widget>requiredThe columns to display in this row.

RadioGroupCardOption<T>

Used by RadioGroup.cards.

ParameterTypeDefaultDescription
valueTrequiredThe value represented by this option.
childBuilderWidget Function(BuildContext, bool isSelected)requiredBuilds the card content; isSelected reflects whether this option is currently selected.

Notes

Internally, table and panel layouts render each row's selection state with RadioIndicator at RadioSize.small, while list-style layouts (simpleList and its variants) render a full Radio control per option.