MihToggle class
A stylized binary switch with integrated labeling.
MihToggle provides a labeled toggle switch that uses the MIH color palette to provide clear visual feedback.
Features:
- Semantic Color Coding: Automatically uses MihColors.green for the "On" state and MihColors.red for the "Off" state.
- Read-Only Mode: When readOnly is true, the toggle is greyed out and interactions are disabled, preserving the UI layout while preventing input.
- Elevation Support: Includes a Material wrapper to allow for shadows and depth, matching other form components.
- State Syncing: Automatically updates its internal position if the initialPostion property is changed by a parent widget.
Example:
MihToggle(
hintText: "Enable Notifications",
initialPostion: true,
fillColor: Colors.blue,
secondaryFillColor: Colors.white,
onChange: (val) => print("Toggle is now: $val"),
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- MihToggle
Constructors
Properties
- darkMode → bool?
-
Whether to use Dark Mode shades for the track colors.
final
- elevation → double?
-
The shadow depth of the toggle container.
final
- fillColor → Color
-
The color of the label text and the outer elevation surface.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hintText → String
-
The label text displayed next to the toggle.
final
- initialPostion → bool
-
The initial state of the toggle (true for on, false for off).
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- onChange → void Function(bool)
-
Callback triggered whenever the toggle state changes.
final
- readOnly → bool?
-
If true, the toggle is displayed in a greyed-out, non-interactive state.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- secondaryFillColor → Color
-
The color of the moving toggle thumb.
final
- width → double?
-
The total width of the toggle row container.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< MihToggle> -
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