fix(onSwipe): fix onSwipe callback being called twice
This commit is contained in:
parent
c763e1f2db
commit
5bf80d010a
|
|
@ -1,3 +1,7 @@
|
|||
## [4.0.2]
|
||||
|
||||
- Fixes `onSwipe` callback being called twice.
|
||||
|
||||
## [4.0.1]
|
||||
|
||||
- Updates the docs.
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Reference in New Issue