Open Jiseeeh opened 7 months ago
I found a solution for that, i added a ValueNotifier for index, then listen SwipeableStack current index from ValueNotifier then call setstate from there.
ValueNotifier<int> pageIndex = ValueNotifier<int>(0);
@override
void initState() {
super.initState();
pageIndex.addListener(() {
int leftCards = cards.length - pageIndex.value;
if (leftCards < 5) {
print('fetching moooooreeee');
fetchMore();
setState(() {});
}
});
}
SwipableStack(
onSwipeCompleted: (index, direction) {
pageIndex.value = index;
if (direction == SwipeDirection.right) {
//handleInteraction(index, false);
} else {
likeCountLeft--;
//handleInteraction(index, true);
}
},
),
Thanks. I'll try it out later
When I call
setState
inside those callbacks, the next time you swipe won't work.