Switch class
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.
Off: [●━━━], On (colored): [━━━●]. Enter or Space toggles it when
focused, as does a click. Passing null for onChanged disables the switch.
- Inheritance
-
- Object
- Widget
- StatelessWidget
- Switch
- Available extensions
Constructors
Properties
- autofocus → bool
-
Whether the switch requests focus when mounted.
final
- focusNode → FocusNode?
-
Optional externally owned focus node used for activation.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
finalinherited
- label → String?
-
Optional visible text and semantic label beside the track.
final
- onChanged → void Function(bool value)?
-
Called with the requested next state on activation; null disables it.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- style → CellStyle?
-
Base styling, plus optional hover, focus, selected, disabled, and invalid
state entries from CellStyle.interactive.
final
- value → bool
-
Controlled on/off state that positions and colors the switch handle.
final
Methods
-
animate(
{Duration? duration, Curve? curve, Object? trigger, bool repeat = false}) → Animate -
Available on Widget, provided by the AnimateExtension extension
Starts an Animate chain over this widget.duration/curveapply to the whole chain. With notriggerit plays on mount; with a non-null trigger it rests on mount and replays whenever the token changes. -
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates the Element that will mount this widget into the tree.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited