flutter_swiper
flutter_swiper copied to clipboard
Unusual left-right swiping (with TINDER and STACK)
Hi,
there seems to be an issue with left-right swiping using
layout: SwiperLayout.STACK //or TINDER
It does not allow natural left or right swiping. It allows them only if previously (in the motion) there was a vertical swipe. Any idea how to fix it ? Thanks
Did you fix it?
I didn't try to fix it yet, but if i do fix it, i'll post my solution here
Listener(
onPointerMove: (moveEvent) {
if (moveEvent.delta.dx > 0) {
print(moveEvent.delta.dx);
print("swipe right");
_controller.previous();
} else if (moveEvent.delta.dx < 0) {
_controller.next();
}
},
child: Swiper(),
This will solve
Thanks. I used your code snippet to make this one that works for me.
bool _swipeRight = false;
bool _swipeLeft = false;
final swipeSensitivity = 40;
...
Listener(
onPointerMove: (moveEvent) {
if (moveEvent.delta.dx > swipeSensitivity) _swipeLeft = true;
if (moveEvent.delta.dx < -swipeSensitivity) _swipeRight = true;
},
onPointerUp: (details) {
if (_swipeLeft && _tabController.index > 0)
_tabController.animateTo(_tabController.index - 1);
else if (_swipeRight && _tabController.index < _tabController.length - 1)
_tabController.animateTo(_tabController.index + 1);
_swipeRight = false;
_swipeLeft = false;
},
child: ...
),
...