StacSwitch class

A Stac model representing Flutter's Switch and CupertinoSwitch widgets.

Displays a toggleable switch that can be turned on or off. The switchType controls whether a Material, Cupertino, or adaptive variant is rendered by the parser.

{@tool snippet} Dart Example:

StacSwitch(
  switchType: StacSwitchType.material,
  value: true,
  onChanged: StacSetValueAction(values: [{'key': 'wifi', 'value': false}]),
  activeColor: StacColors.green,
)

{@end-tool}

{@tool snippet} JSON Example:

{
  "type": "switch",
  "switchType": "material",
  "value": true,
  "onChanged": {"type": "setValue", "key": "wifi", "value": false},
  "activeColor": "#4CAF50"
}

{@end-tool}

Inheritance
Annotations
  • @JsonSerializable.new(explicitToJson: true)

Constructors

StacSwitch({StacSwitchType? switchType, bool? value, StacAction? onChanged, bool? autofocus, StacColor? activeThumbColor, StacColor? activeTrackColor, StacColor? focusColor, StacColor? hoverColor, StacColor? inactiveThumbColor, StacColor? inactiveTrackColor, StacColor? onLabelColor, StacColor? offLabelColor, double? splashRadius, StacDragStartBehavior? dragStartBehavior, StacColor? overlayColor, StacColor? thumbColor, StacColor? trackColor, StacMaterialTapTargetSize? materialTapTargetSize, StacColor? trackOutlineColor, double? trackOutlineWidth, StacWidget? thumbIcon, String? inactiveThumbImage, String? activeThumbImage, bool? applyTheme, bool? applyCupertinoTheme})
Creates a StacSwitch.
const
StacSwitch.fromJson(Map<String, dynamic> json)
Creates a StacSwitch from a JSON map.
factory

Properties

activeThumbColor → StacColor?
The color to use when this switch is on.
final
activeThumbImage → StacColor?
Network image URL to display on the thumb when the switch is on (Material only).
final
activeTrackColor → StacColor?
The color to use for the track when this switch is on (Material only).
final
applyCupertinoTheme → bool?
Whether to apply the current Cupertino theme when using an adaptive switch.
final
applyTheme → bool?
Whether to apply the current Cupertino theme to the CupertinoSwitch.
final
autofocus → bool?
Whether this switch should focus itself if nothing else is focused.
final
dragStartBehavior → StacDragStartBehavior?
Determines when a drag gesture should start.
final
focusColor → StacColor?
The color to use for the focus highlight.
final
hashCode → int
The hash code for this object.
no setterinherited
hoverColor → StacColor?
The color to use for the hover highlight.
final
inactiveThumbColor → StacColor?
The color to use for the thumb when this switch is off (Material only).
final
inactiveThumbImage → StacColor?
Network image URL to display on the thumb when the switch is off (Material only).
final
inactiveTrackColor → StacColor?
The color to use for the track when this switch is off (Material only).
final
jsonData → Map<String, dynamic>?
Raw JSON data for this widget
finalinherited
materialTapTargetSize → StacMaterialTapTargetSize?
Configures the minimum size of the area within which the switch may be pressed.
final
offLabelColor → StacColor?
The color to use for the OFF label (Cupertino only).
final
onChanged → StacAction?
Action invoked when the user toggles the switch.
final
onLabelColor → StacColor?
The color to use for the ON label (Cupertino only).
final
overlayColor → StacColor?
The overlay color for the switch's ink response.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
splashRadius → double?
The splash radius of the switch's splash in logical pixels.
final
switchType → StacSwitchType?
Which platform style of switch to render.
final
thumbColor → StacColor?
The color of the switch thumb for Material (via MaterialStateProperty uniform value).
final
thumbIcon → StacWidget?
The icon to display on the thumb for Material (via MaterialStateProperty uniform value). Provide an Icon widget.
final
trackColor → StacColor?
The color of the switch track for Material (via MaterialStateProperty uniform value).
final
trackOutlineColor → StacColor?
The outline color of the track for Material (via MaterialStateProperty uniform value).
final
trackOutlineWidth → double?
The outline width of the track for Material (via MaterialStateProperty uniform value).
final
type → String
Widget type identifier.
no setteroverride
value → bool?
Whether this switch is on.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, dynamic>
Converts this StacSwitch instance to a JSON map.
override
toString() → String
A string representation of this object.
inherited

Operators

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