HeavenOSK / flutter_swipable_stack

A widget for stacking cards, which users can swipe horizontally and vertically with beautiful animations like Tinder UI.
https://pub.dev/packages/swipable_stack
MIT License
117 stars 48 forks source link

Add an updateCallback for SwipeableStack #64

Open therealjohnsummer opened 2 years ago

therealjohnsummer commented 2 years ago

I have a suggestion but first - Thanks for a great component.

Can we add an onSwipeUpdate callback that is passed SwipeDirection and SwipeProgress or else add them to the SwipableStackController ?

These values should be part of the controller so that the controller can be used in other Widgets (I need to provide additionally animation when a card is moved).

Currently the only way to get access to these values is via the OverlayBuilder which causes rebuild issues if animation is triggered from that callback.

Ideally we should have either the SwipableStackController enriched with these values or else provide an onSwipeUpdate(properties) callback.

mghali1 commented 1 year ago

Hello @therealjohnsummer ,

Not sure if these will help, but maybe you can use onWillMoveNext: (index, swipeDirection) param which will be called right before the swipe starts. You should return true or false to allow or prevent the swipe, but you can do anything before that, and you have access to the swipeDirection.

Also, you can use onSwipeCompleted: (index, direction) which will be called once the swipe is fully completed.