ToggleableStateMixin<S extends StatefulWidget> mixin Null safety

A mixin for StatefulWidgets that implement material-themed toggleable controls with toggle animations (e.g. Switches, Checkboxes, and Radios).

The mixin implements the logic for toggling the control (e.g. when tapped) and provides a series of animation controllers to transition the control from one state to another. It does not have any opinion about the visual representation of the toggleable widget. The visuals are defined by a CustomPainter passed to the buildToggleable. State objects using this mixin should call that method from their build method.

This mixin is used to implement the material components for Switch, Checkbox, and Radio controls.

Superclass Constraints


positionController AnimationController
Used by subclasses to manipulate the visual value of the control.
position CurvedAnimation
The visual value of the control.
reactionController AnimationController
Used by subclasses to control the radial reaction animation.
reaction Animation<double>
The visual value of the radial reaction animation.
reactionHoverFade Animation<double>
Controls the radial reaction's opacity animation for hover changes.
reactionFocusFade Animation<double>
Controls the radial reaction's opacity animation for focus changes.
isInteractive bool
Whether value of this control can be changed by user interaction.
onChanged ValueChanged<bool?>?
Called when the control changes value.
value bool?
False if this control is "inactive" (not checked, off, or unselected).
tristate bool
If true, value can be true, false, or null, otherwise value must be true or false.
downPosition Offset?
The most recent Offset at which a pointer touched the Toggleable.
states Set<MaterialState>
Describes the current MaterialState of the Toggleable.
widget → S
The current configuration.
read-only, inherited
context BuildContext
The location in the tree where this widget builds.
read-only, inherited
mounted bool
Whether this State object is currently in a tree.
read-only, inherited
hashCode int
The hash code for this object.
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


activate() → void
Called when this object is reinserted into the tree after having been removed via deactivate.
animateToValue() → void
Runs the position animation to transition the Toggleable's appearance to match value.
build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
@protected, inherited
buildToggleable({FocusNode? focusNode, bool autofocus = false, required MaterialStateProperty<MouseCursor> mouseCursor, required Size size, required CustomPainter painter}) Widget
Typically wraps a painter that draws the actual visuals of the Toggleable with logic to toggle it.
createTicker(TickerCallback onTick) Ticker
Creates a ticker with the given callback.
deactivate() → void
Called when this object is removed from the tree.
@mustCallSuper, @protected, inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
didChangeDependencies() → void
Called when a dependency of this State object changes.
@mustCallSuper, @protected, inherited
didUpdateWidget(covariant S oldWidget) → void
Called whenever the widget configuration changes.
@mustCallSuper, @protected, inherited
dispose() → void
Called when this object is removed from the tree permanently.
initState() → void
Called when this object is inserted into the tree.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
reassemble() → void
Called whenever the application is reassembled during debugging, for example during hot reload.
@mustCallSuper, @protected, inherited
setState(VoidCallback fn) → void
Notify the framework that the internal state of this object has changed.
@protected, inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
toString({DiagnosticLevel minLevel =}) String
A string representation of this object.
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode.


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