SSwitch class

An elegant, heavily customizable switch component for toggling binary states.

The SSwitch natively supports animations, size variants, custom track widgets, and an embedded thumbIcon while cleanly matching system design aesthetics.

Inheritance

Constructors

SSwitch({Key? key, required bool value, required ValueChanged<bool>? onChanged, bool loading = false, SSwitchSize size = SSwitchSize.medium, Color? activeColor, Color? inactiveColor, Color? thumbColor, Widget? checkedChildren, Widget? unCheckedChildren, Widget? thumbIcon, bool disabled = false, String? semanticLabel})
const

Properties

activeColor Color?
The background color of the switch track when it is turned on. Falls back to your application's primary theme color.
final
checkedChildren Widget?
A widget (usually text or an icon) displayed inside the track's left side when the switch is turned ON.
final
disabled bool
Determines if the switch is interactable. When true, the switch ignores interaction and visually dims.
final
hashCode int
The hash code for this object.
no setterinherited
inactiveColor Color?
The background color of the switch track when it is turned off.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
loading bool
If true, a circular loading spinner is rendered inside the thumb and the switch ignores interaction.
final
onChanged ValueChanged<bool>?
Callback fired when the user taps on the switch. The switch does not mutate its own state; it expects the parent to update value.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
semanticLabel String?
An optional semantic representation of the switch, highly recommended for Accessibility/TalkBack tools.
final
size SSwitchSize
The physical sizing scale of the switch (defaults to SSwitchSize.medium).
final
thumbColor Color?
The color of the moving circular thumb. Defaults to white if null.
final
thumbIcon Widget?
A widget (usually an Icon) that is rendered directly inside the moving thumb circle. Automatically scaled and perfectly centered via FittedBox.
final
unCheckedChildren Widget?
A widget (usually text or an icon) displayed inside the track's right side when the switch is turned OFF.
final
value bool
Determines whether the switch is currently turned on (true) or off (false).
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<SSwitch>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited