jushutch / swiping_card_deck

A widget for swiping through a deck of cards with gestures or buttons.
https://pub.dev/packages/swiping_card_deck
BSD 3-Clause "New" or "Revised" License
13 stars 10 forks source link

How can I get index of the current card #20

Closed nferdazel closed 2 years ago

nferdazel commented 2 years ago

function onSwipeLeft, onSwipeRight only provide Card parameter to pass. How to get the current card index though? I don't know how to leverage this function. Thank you

jushutch commented 2 years ago

Hello @nferdazel, thank you for opening this issue! You are correct that currently onSwipeLeft and onSwipeRight only take in the Card as a parameter. If you want to get the index of the current card in those functions, I recommend creating a class that extends the Card class and adds an index property that you set when the cards are created. Then you can access this property of the Card parameter in those functions. There might be other ways to accomplish this, but this is the first one I could think of. I'm also open to adding the index as a parameter for those functions, I can see how that would be useful. If you want, you can open a pull request with the change required to do that, otherwise I can look into it.

nferdazel commented 2 years ago

@jushutch Thank you for providing the workaround regarding my question. I'm quite new into this field and not yet confident to open any pull request, but I will try to implement the solution. Once again, thank you

jushutch commented 2 years ago

Hi @nferdazel, I just published pre-release v2.0.0-dev.0 which resolves this issue! To read about the new feature, checkout out Pull Request #26. You can use the new cardsSwiped parameter in the onSwipe callback functions, which can be used to determine the current index of the deck. Let me know if you have any questions about this change! To use the pre-release version with this feature, just change your pubspec.yaml to:

swiping_card_deck: 2.0.0-dev.0

Feel free to leave feedback on this change and let me know if you have any suggestions before I release it in v2.0.0. Thank you again for opening this issue!

nferdazel commented 2 years ago

Hi @nferdazel, I just published pre-release v2.0.0-dev.0 which resolves this issue! To read about the new feature, checkout out Pull Request #26. You can use the new cardsSwiped parameter in the onSwipe callback functions, which can be used to determine the current index of the deck. Let me know if you have any questions about this change! To use the pre-release version with this feature, just change your pubspec.yaml to:

swiping_card_deck: 2.0.0-dev.0

Feel free to leave feedback on this change and let me know if you have any suggestions before I release it in v2.0.0. Thank you again for opening this issue!

Hello, this is awesome! Thank you very much for updating the package, I will try this ASAP and give you feedback.

nferdazel commented 2 years ago

Hi @nferdazel, I just published pre-release v2.0.0-dev.0 which resolves this issue! To read about the new feature, checkout out Pull Request #26. You can use the new cardsSwiped parameter in the onSwipe callback functions, which can be used to determine the current index of the deck. Let me know if you have any questions about this change! To use the pre-release version with this feature, just change your pubspec.yaml to:

swiping_card_deck: 2.0.0-dev.0

Feel free to leave feedback on this change and let me know if you have any suggestions before I release it in v2.0.0. Thank you again for opening this issue!

Hi @jushutch, I hope you great day. I just want to confirm/follow up that the index parameter works well for me. Thank you for the hard work, and sorry for the late response. I just have the chance to try the changes today.