AuiSwitch class

A fully custom animated toggle switch widget that matches the AuraUI aesthetic.

The track animates its color between activeColor and inactiveColor, and the thumb slides left↔right using AnimatedPositioned.

Example usage:

AuiSwitch(
  value: _isOn,
  onChanged: (v) => setState(() => _isOn = v),
  label: 'Enable notifications',
)
Inheritance

Constructors

AuiSwitch({Key? key, required bool value, required ValueChanged<bool>? onChanged, String? label, SwitchLabelPosition labelPosition = SwitchLabelPosition.left, Color? activeColor, Color? inactiveColor, Color activeThumbColor = Colors.white, bool disabled = false, double size = 1.0})
Creates an AuiSwitch.
const

Properties

activeColor Color?
Track color when value is true. Defaults to Theme.of(context).colorScheme.primary.
final
activeThumbColor Color
Color of the circular thumb. Defaults to Colors.white.
final
disabled bool
When true the switch is rendered at 50 % opacity and ignores taps.
final
hashCode int
The hash code for this object.
no setterinherited
inactiveColor Color?
Track color when value is false. Defaults to Colors.grey.shade300.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
label String?
Optional text label rendered next to the track.
final
labelPosition SwitchLabelPosition
Position of label relative to the track. Defaults to SwitchLabelPosition.left.
final
onChanged ValueChanged<bool>?
Called when the user taps the switch. Pass null to disable tap handling (prefer using disabled instead so opacity is also applied).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size double
Scale factor applied to all dimensions. 0.8 = small, 1.0 = normal, 1.2 = large.
final
value bool
Whether the switch is currently on.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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