Widgets

CupertinoSwitch

CupertinoSwitch

CupertinoSwitch control. Build it with the cupertino_switch helper.

Example

cupertino_switch(
  value: "Sample",
  label: "Label",
  expand: true,
  width: 240,
  on_change: ->(event) {}
)

Properties

  • active_thumb_image — Sets the active thumb image property.
  • active_thumb_image_src — Sets the active thumb image src property.
  • active_track_color — Active track color.
  • autofocus — Requests focus when first shown.
  • focus_color — Color shown while focused.
  • inactive_thumb_color — Inactive thumb color.
  • inactive_thumb_image — Sets the inactive thumb image property.
  • inactive_thumb_image_src — Sets the inactive thumb image src property.
  • inactive_track_color — Inactive track color.
  • label — Text label shown for the control.
  • label_position — Sets the label position property.
  • off_label_color — Off label color.
  • thumb_color — Thumb color.
  • thumb_icon — Thumb icon.
  • track_outline_color — Track outline color.
  • track_outline_width — Track outline width.
  • value — The control's current value.
  • on_label_color — On label color.

Common layout and animation properties

  • align — Alignment of the control within its parent.
  • animate_align — Animates alignment changes.
  • animate_margin — Animates margin changes.
  • animate_offset — Animates offset changes.
  • animate_opacity — Animates opacity changes.
  • animate_position — Animates position changes.
  • animate_rotation — Animates rotation changes.
  • animate_scale — Animates scale changes.
  • animate_size — Animates size changes.
  • aspect_ratio — Width-to-height ratio to maintain.
  • badge — Badge drawn on the corner of the control.
  • bottom — Bottom offset when positioned inside a stack.
  • col — Responsive column span (1-12) per breakpoint.
  • data — Arbitrary value you can attach to the control and read back in handlers.
  • disabled — Disables interaction when true.
  • expand — Fills the available space along the parent's main axis when true.
  • expand_loose — Like expand, but only grows up to the child's natural size.
  • height — Fixed height in logical pixels.
  • key — Stable identity used to preserve state across rebuilds.
  • left — Left offset when positioned inside a stack.
  • margin — Outer spacing around the control.
  • offset — Translation offset applied to the control.
  • opacity — Opacity from 0.0 (transparent) to 1.0 (opaque).
  • right — Right offset when positioned inside a stack.
  • rotate — Rotation applied to the control.
  • rtl — Renders right-to-left when true.
  • scale — Scale transform applied to the control.
  • size_change_interval — Throttle interval for on_size_change, in ms.
  • tooltip — Text shown on hover/long-press.
  • top — Top offset when positioned inside a stack.
  • visible — Hides the control when false.
  • width — Fixed width in logical pixels.

Events

  • on_animation_end — Fired when an animation completes.
  • on_blur — Fired when the control loses focus.
  • on_change — Fired when the value changes.
  • on_focus — Fired when the control gains focus.
  • on_image_error — Fired when the image fails to load.
  • on_size_change — Fired when the control's size changes.

Reference

  • Family: cupertinos
  • Widget type: cupertinoswitch
  • Helpers: cupertino_switch, cupertinoswitch