Skip to content

feat: add enableSwipe parameter for gesture-based selection (#71)#104

Open
Vasusn wants to merge 1 commit intoPramodJoshi:masterfrom
Vasusn:feat/issue-71-swipe-gesture
Open

feat: add enableSwipe parameter for gesture-based selection (#71)#104
Vasusn wants to merge 1 commit intoPramodJoshi:masterfrom
Vasusn:feat/issue-71-swipe-gesture

Conversation

@Vasusn
Copy link
Copy Markdown

@Vasusn Vasusn commented Apr 26, 2026

Problem

Users requested the ability to swipe between toggle options (issue #71), especially useful for 2-option switches.

Solution

Added an enableSwipe parameter (default: false). When enabled, a swipe right/down advances selection by one step and swipe left/up retreats selection by one step. Swipes beyond the first or last switch are ignored.

Changes

  • lib/toggle_switch.dart: added enableSwipe field, constructor param, and _handleSwipe method; wrapped RowToColumn in GestureDetector
  • test/toggle_switch_test.dart: three new tests covering swipe right, swipe left, and swipe disabled (default)

Fixes #71

Copilot AI review requested due to automatic review settings April 26, 2026 10:19
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds optional swipe gestures to ToggleSwitch so users can change the selected index via horizontal/vertical swipes when enableSwipe is enabled (default off), addressing issue #71.

Changes:

  • Introduces enableSwipe parameter and wraps the switch layout with a GestureDetector to handle swipe gestures.
  • Adds _handleSwipe to advance/retreat selection based on swipe direction.
  • Adds example usage and widget tests for basic swipe behavior and the default-disabled behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
lib/toggle_switch.dart Adds enableSwipe API and swipe gesture handling via GestureDetector + _handleSwipe.
test/toggle_switch_test.dart Adds widget tests for swipe right/left when enabled and no effect when disabled.
example/lib/main.dart Demonstrates enableSwipe: true usage in the example app.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/toggle_switch.dart Outdated
Comment thread lib/toggle_switch.dart Outdated
Comment thread test/toggle_switch_test.dart
Comment thread lib/toggle_switch.dart
Comment thread lib/toggle_switch.dart
…shi#71)

## Problem
Users requested the ability to swipe between toggle options
(issue PramodJoshi#71), especially useful for 2-option switches.

## Solution
Added an `enableSwipe` parameter (default: `false`). When enabled,
a swipe right/down advances selection by one step and swipe left/up
retreats selection by one step. Swipes beyond the first or last switch
are ignored.

## Changes
- lib/toggle_switch.dart: added `enableSwipe` field, constructor param,
  and `_handleSwipe` method; wrapped RowToColumn in GestureDetector
- test/toggle_switch_test.dart: three new tests covering swipe right,
  swipe left, and swipe disabled (default)

Fixes PramodJoshi#71
@Vasusn Vasusn force-pushed the feat/issue-71-swipe-gesture branch from b699325 to dc75deb Compare April 26, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Swipe Feature

2 participants