ShadSwitch class

A customizable switch widget, styled according to the Shadcn UI design system.

Allows users to toggle between two states: on or off.

Inheritance
Available extensions

Constructors

ShadSwitch({Key? key, required bool value, bool enabled = true, ValueChanged<bool>? onChanged, FocusNode? focusNode, Color? thumbColor, Color? uncheckedTrackColor, Color? checkedTrackColor, double? width, double? height, double? margin, Duration? duration, ShadDecoration? decoration, TextDirection? direction, Widget? label, Widget? sublabel, EdgeInsetsGeometry? padding})
A customizable switch widget, styled according to the Shadcn UI design system.
const

Properties

checkedTrackColor Color?
Color of the track when the switch is in the checked (on) state.
final
decoration ShadDecoration?
Custom decoration for the switch track.
final
direction TextDirection?
Text direction of the switch and associated label.
final
duration Duration?
Duration of the animation when toggling the switch.
final
enabled bool
Whether the switch is enabled and can be interacted with.
final
focusNode FocusNode?
Focus node to control the focus state of the switch.
final
hashCode int
The hash code for this object.
no setterinherited
height double?
Height of the switch widget.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label Widget?
Widget to display as a label for the switch.
final
margin double?
Margin around the thumb within the track.
final
onChanged ValueChanged<bool>?
Callback function invoked when the switch is toggled.
final
padding EdgeInsetsGeometry?
Padding between the switch itself and its label.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sublabel Widget?
Widget to display as a sublabel, providing additional context below the label.
final
thumbColor Color?
Color of the switch's thumb (the draggable part).
final
uncheckedTrackColor Color?
Color of the track when the switch is in the unchecked (off) state.
final
value bool
Whether the switch is currently on or off.
final
width double?
Width of the switch widget.
final

Methods

animate({Key? key, List<Effect>? effects, AnimateCallback? onInit, AnimateCallback? onPlay, AnimateCallback? onComplete, bool? autoPlay, Duration? delay, AnimationController? controller, Adapter? adapter, double? target, double? value}) Animate

Available on Widget, provided by the AnimateWidgetExtensions extension

Wraps the target Widget in an Animate instance, and returns the instance for chaining calls. Ex. myWidget.animate() is equivalent to Animate(child: myWidget).
createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<ShadSwitch>
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
positionedWith(ShadPosition position) Widget

Available on Widget, provided by the PositionedExt extension

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