Skip to main content
The Stac Switch widget allows you to build the Flutter Switch widget using JSON. To know more about the Switch widget in Flutter, refer to the official documentation.

Properties

PropertyTypeDescription
switchTypeStacSwitchTypeThe type of the Switch.
valueboolWhether this switch is on or off.
onChangedStacActionCalled when the user toggles the switch on or off.
autofocusboolTrue if this widget will be selected as the initial focus when no other node in its scope is currently focused.
activeThumbColorStacColorThe color to use when this switch is on.
activeTrackColorStacColorThe color to use on the track when this switch is on.
focusColorStacColorThe color for the button’s when it has the input focus.
hoverColorStacColorThe color for the button’s when a pointer is hovering over it.
inactiveThumbColorStacColorThe color to use on the thumb when this switch is off.
inactiveTrackColorStacColorThe color to use on the track when this switch is off.
onLabelColorStacColorThe color to use for the accessibility label when the switch is on.
offLabelColorStacColorThe color to use for the accessibility label when the switch is off.
splashRadiusdoubleThe splash radius of the circular ink response.
dragStartBehaviorStacDragStartBehaviorDetermines the way that drag start behavior is handled.
overlayColorStacMaterialColorThe color for the switch.
thumbColorStacMaterialColorThe color of this Switch’s thumb.
trackColorStacMaterialColorTThe color of this Switch’s track.
materialTapTargetSizeStacMaterialTapTargetSizeConfigures the minimum size of the tap target.
trackOutlineColorStacMaterialColorThe outline color of this Switch’s track.
thumbIconStacWidgetThe icon to use on the thumb of this switch.
inactiveThumbImageStringAn image to use on the thumb of this switch when the switch is off.
activeThumbImageStringAn image to use on the thumb of this switch when the switch is on.
applyThemeboolWhether to apply the ambient theme data.
applyCupertinoThemeboolWhether to apply the ambient theme data.

Example

Example 1: Cupertino Switch

StacSwitch(
  switchType: StacSwitchType.cupertino,
  value: true,
)

Example 2: Adaptive Switch

StacSwitch(
  switchType: StacSwitchType.adaptive,
  value: true,
)

Example 3: Material Switch

StacSwitch(
  switchType: StacSwitchType.material,
  value: false,
)