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

Problem with end of stack #48

Closed nanox77 closed 2 years ago

nanox77 commented 2 years ago

Hi, I have a problem when end of the stack came. I implemented two ways but I didn't success.

1. Following this issue https://github.com/HeavenOSK/flutter_swipable_stack/issues/12 I added a listener like you suggested:

    _controller = SwipableStackController()
      ..addListener(() {
        if (_users.length - 1 <= _controller.currentIndex) {
          print('loading more users');
        }
        setState(() {});
      });

But when the last card is being swiped then listener is executed extremely times:

11 I[/flutter]() ( 6322): loading more users
11 I[/flutter]() ( 6322): loading more users
11 I[/flutter]() ( 6322): loading more users
11 I[/flutter]() ( 6322): loading more users

2. I thought: ok, so when the last card is shown I can use onSwipeCompleted callback to reset currentItem = 0 but didn't work because the library internally execute +1 on currentIndex, then SwipableStack shows again the last card.

Is there a solution for this problem?.

Thank you!!