Skip to main content

Examples

Toggle switch example

Toggle switch with on and off states.

NeoToggleSwitch(
  isOn: false,
  onChanged: (value) {
    // Handle state change
  },
),

Properties

Required

isOn
bool
required
The current state of the toggle switch. true represents the “on” state, false represents the “off” state.
onChanged
ValueChanged<bool>
required
Callback function called when the toggle state changes. Receives the new boolean value.

State

isEnabled
bool
default:"true"
Controls whether the toggle switch is interactive. When false, the switch dims, ignores input and focus, and shows a forbidden cursor while still displaying its current on/off state.

Best Practices

  • Combine with NeoHaptics in the onChanged callback for enhanced user experience on supported devices.

Integration Notes

  • Input Methods: Supports both tap and drag interactions:
    • Tap: Single tap anywhere on the switch toggles the state
    • Drag: Horizontal drag allows intuitive dragging to toggle
I