Tinyrack

Radio

Offer one option inside a mutually exclusive radio group.

Offer one option inside a mutually exclusive radio group.

Contract

AxisContract
SelectionSelected while the group value equals this value. A radio never sets its own state; the group does.
Labellabel renders beside the glyph as one tappable target and one semantic node. Compound labels align the glyph with their first body line by default; choose TRRadioLabelAlignment.center for non-text content. Style text with TRText.
SizeuiSize takes TRUiSize.md or TRUiSize.lg; the default is md. Match it to the controls around the option.
Availabilitydisabled and readOnly combine with the values the group sets. readOnly keeps the option focusable and its value intact; disabled blocks interaction and dims the option.
KeyboardSpace selects the focused option on key release, matching a native radio. Moving between options belongs to TRRadioGroup.

A radio only means something inside TRRadioGroup, which owns the selected value. Give every option a value that is unique within its group and a label a reader can act on. For a standalone on or off control use TRCheckbox or TRSwitch instead.

Install

Add the package, then import its public library.

flutter pub add tinyrack_ui
import 'package:tinyrack_ui/tinyrack_ui.dart';

Playground

Usage

import 'package:material_ui/material_ui.dart';
import 'package:tinyrack_ui/tinyrack_ui.dart';

TRRadioGroup(
  defaultValue: 'weekly',
  onValueChange: setSchedule,
  children: const [
    TRRadio(
      value: 'weekly',
      label: TRText('Weekly', variant: TRTextVariant.bodySm),
    ),
    TRRadio(
      value: 'monthly',
      label: TRText('Monthly', variant: TRTextVariant.bodySm),
    ),
  ],
)

Examples

Unselected and selected permalink

Selection is meaningful only against the value the group holds, so compare both options inside one group.

Medium and large permalink

Match md or lg to the density of the controls around the option.

Editable, read only, and disabled permalink

Set availability on one option when it differs from the rest; otherwise set it once on the group.

API

TRRadio properties

PropType / defaultPurpose
valueString · requiredIdentifies the option inside its group. Keep it unique and stable.
labelWidget? · nullRenders beside the glyph and joins it as one tap target and one semantic node. Without it the option shows only the glyph.
uiSizeTRUiSize · TRUiSize.mdSets the glyph and indicator size.
disabledbool · falseBlocks interaction for this option, on top of the group value. Disabled options are skipped by the arrow keys.
readOnlybool · falseKeeps the option focusable and its value visible while refusing changes.
invalidbool · falsePaints the danger border. Drive it from your own validation; the widget never sets it.
focusNode, autofocusFocusNode? · null, bool · falseAn explicit focusNode replaces the one the group manages for this option.