Compare commits
1 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
b617e09aed |
|
|
@ -1,3 +1,8 @@
|
||||||
|
## [7.1.0]
|
||||||
|
|
||||||
|
- Adds support for tapping a card
|
||||||
|
- `onTap` callback containing currentIndex.
|
||||||
|
|
||||||
## [7.0.2]
|
## [7.0.2]
|
||||||
|
|
||||||
- Added `CardAnimation.animateToAngle` helper to animate swipe the card to any given angle between 0-360°.
|
- Added `CardAnimation.animateToAngle` helper to animate swipe the card to any given angle between 0-360°.
|
||||||
|
|
|
||||||
|
|
@ -36,4 +36,4 @@ typedef CardSwiperOnUndo = bool Function(
|
||||||
CardSwiperDirection direction,
|
CardSwiperDirection direction,
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef CardSwiperOnTap = FutureOr<void> Function();
|
typedef CardSwiperOnTap = FutureOr<void> Function(int currentIndex);
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ class _CardSwiperState<T extends Widget> extends State<CardSwiper>
|
||||||
if (widget.isDisabled) {
|
if (widget.isDisabled) {
|
||||||
await widget.onTapDisabled?.call();
|
await widget.onTapDisabled?.call();
|
||||||
}
|
}
|
||||||
await widget.onTap?.call();
|
await widget.onTap?.call(_currentIndex!);
|
||||||
},
|
},
|
||||||
onPanStart: (tapInfo) {
|
onPanStart: (tapInfo) {
|
||||||
if (!widget.isDisabled) {
|
if (!widget.isDisabled) {
|
||||||
|
|
|
||||||
|
|
@ -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.
|
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
|
homepage: https://github.com/ricardodalarme/flutter_card_swiper
|
||||||
issue_tracker: https://github.com/ricardodalarme/flutter_card_swiper/issues
|
issue_tracker: https://github.com/ricardodalarme/flutter_card_swiper/issues
|
||||||
version: 7.0.2
|
version: 7.1.0
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=3.0.0 <4.0.0"
|
sdk: ">=3.0.0 <4.0.0"
|
||||||
|
|
|
||||||
|
|
@ -637,24 +637,25 @@ void main() {
|
||||||
|
|
||||||
testWidgets('when tapping a card, expect callback', (WidgetTester tester) async {
|
testWidgets('when tapping a card, expect callback', (WidgetTester tester) async {
|
||||||
final swiperKey = GlobalKey();
|
final swiperKey = GlobalKey();
|
||||||
var isCalled = false;
|
var index = -1;
|
||||||
|
|
||||||
await tester.pumpApp(
|
await tester.pumpApp(
|
||||||
CardSwiper(
|
CardSwiper(
|
||||||
key: swiperKey,
|
key: swiperKey,
|
||||||
cardsCount: 3,
|
cardsCount: 3,
|
||||||
numberOfCardsDisplayed: 1,
|
numberOfCardsDisplayed: 1,
|
||||||
onTap: () {
|
initialIndex: 2,
|
||||||
isCalled = true;
|
onTap: (currentIndex) {
|
||||||
|
index = currentIndex;
|
||||||
},
|
},
|
||||||
cardBuilder: genericBuilder,
|
cardBuilder: genericBuilder,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
await tester.dragDown(swiperKey);
|
await tester.tap(find.byKey(swiperKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(isCalled, true);
|
expect(index, 2);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue