fix(onSwipe): fix onSwipe callback being called twice

This commit is contained in:
ricardodalarme 2023-03-25 10:18:54 -03:00
parent c763e1f2db
commit 5bf80d010a
3 changed files with 6 additions and 9 deletions

View File

@ -1,3 +1,7 @@
## [4.0.2]
- Fixes `onSwipe` callback being called twice.
## [4.0.1]
- Updates the docs.

View File

@ -361,16 +361,9 @@ class _CardSwiperState<T extends Widget> extends State<CardSwiper>
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();
}

View File

@ -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"