Skip to content

Switch

A wider, accent-tinted boolean switch — visually distinct from Toggle for cases where you want the on/off state to stand out at a glance (settings panels, feature flags). When value: true the track tints in the theme’s primary color and the handle sits on the right; when false the track is muted and the handle sits on the left.

See also: Toggle for a compact on/off switch · Checkbox for a checklist item.

Learn more: Forms & validation

Import: package:fleury/fleury.dart, or package:fleury/fleury_core.dart in browser code.

Switch(
value: _streaming,
label: 'Streaming updates',
onChanged: (value) => setState(() => _streaming = value),
)

Off: [●━━━], On (colored): [━━━●]. Enter or Space toggles it when focused, as does a click. Passing null for onChanged disables the switch.

ParameterTypeDefaultDescription
value:boolrequiredControlled on/off state that positions and colors the switch handle.
onChanged:void Function(bool value)?requiredCalled with the requested next state on activation; null disables it.
label:String?—Optional visible text and semantic label beside the track.
focusNode:FocusNode?—Optional externally owned focus node used for activation.
autofocus:boolfalseWhether the switch requests focus when mounted.
style:CellStyle?—Base styling, plus optional hover, focus, selected, disabled, and invalid state entries from CellStyle.interactive.

Switch is defined in packages/fleury/lib/src/catalog/controls.dart.

Category: Inputs & controls · All widgets