Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwipeableWidget.builder #6

Open
SncOne opened this issue May 18, 2020 · 1 comment
Open

SwipeableWidget.builder #6

SncOne opened this issue May 18, 2020 · 1 comment

Comments

@SncOne
Copy link

SncOne commented May 18, 2020

Is it possible to add this feature

@ninest
Copy link
Owner

ninest commented May 19, 2020

I believe you want it similar to ListView.builder? While it isn't there in the same way, check out the example here: https://github.com/ninest/swipeable_card/blob/v1.x.x/example/lib/example_route.dart

Basically, you have a list of your cards and the current card index. Your current card is shown as a child of SwipeableWidget, and the next card(s) is put into the nextCards parameter. This way, you are only showing the top card and the card behind it. You can, for example, show the next 3 cards if you put something like this as the nextCards parameter:

cards[currentCardIndex + 3],
cards[currentCardIndex + 2],
cards[currentCardIndex + 1]

A more complex example can be found in my Shots app, this file especially.

If you see the demo, you can see the top card and cards behind it. I've put all cards at a random offset and angle. While it looks like you can see the entire deck, you are actually only look at the top card and 3 cards behind it. If you notice, when the top card is swiped, another card is being added the end of the list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants