From 5bf80d010a1f087a8362b6ab57bbad561c3a8cd3 Mon Sep 17 00:00:00 2001 From: ricardodalarme Date: Sat, 25 Mar 2023 10:18:54 -0300 Subject: [PATCH] fix(onSwipe): fix onSwipe callback being called twice --- CHANGELOG.md | 4 ++++ lib/src/card_swiper.dart | 9 +-------- pubspec.yaml | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 275b588..215889e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [4.0.2] + +- Fixes `onSwipe` callback being called twice. + ## [4.0.1] - Updates the docs. diff --git a/lib/src/card_swiper.dart b/lib/src/card_swiper.dart index af92b1a..eeb0a4a 100644 --- a/lib/src/card_swiper.dart +++ b/lib/src/card_swiper.dart @@ -361,16 +361,9 @@ class _CardSwiperState extends State return; } - final previousIndex = _currentIndex; - final isLastCard = _currentIndex == widget.cardsCount - 1; - _currentIndex = _nextIndex; - widget.onSwipe?.call( - previousIndex, - _currentIndex, - detectedDirection, - ); + final isLastCard = _currentIndex == widget.cardsCount - 1; if (isLastCard) { widget.onEnd?.call(); } diff --git a/pubspec.yaml b/pubspec.yaml index 7caa891..338ef18 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: flutter_card_swiper description: This is a Tinder-like card swiper package. It allows you to swipe left, right, up, and down and define your own business logic for each direction. homepage: https://github.com/ricardodalarme/flutter_card_swiper issue_tracker: https://github.com/ricardodalarme/flutter_card_swiper/issues -version: 4.0.1 +version: 4.0.2 environment: sdk: ">=2.12.0 <3.0.0"