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

Change Card to Widget #18

Closed ihorbokov closed 2 years ago

ihorbokov commented 2 years ago

Hey @jushutch! What do you think about changing List<Card> of swappable widgets to List<Widget> in order to make library more flexible? As I see there aren't any special things from the Card to be used.

jushutch commented 2 years ago

Hi @phimary, that's definitely an interesting idea! You have a good point about no special Card properties being used. I originally decided to use a list of Card widgets to make it more specific to the idea of a swiping card deck. The idea was that developers could extend the Card class with their own card widgets. Changing it to a List<Widget> would loosen that restriction, which would be good for using widgets other than cards as you mentioned, but could make the package more confusing or inconsistent. Currently the swiping_card_deck widget depends on a cardWidth parameter as well, with the expectation that all cards have a uniform width in order to make the swipe animation work; we'd have to make sure that arbitrary widgets would also swipe well. I'll definitely look into making it an option though, maybe even using optional templating like swiping_card_deck<Widget>. Feel free to add your thoughts, especially about specific use cases or times where you need widgets instead of cards, and also potential pros and cons!

tldr; It's a great idea, I'll look into it and I'm open to any ideas or solutions

ihorbokov commented 2 years ago

Hi @jushutch! Got it! Yep, it's clear to me - thanks a lot!

jushutch commented 2 years ago

@phimary @boxOfAces I just released v1.2.0 which includes support for decks of any Widget! :tada: You can still use the SwipingCardDeck widget as you did before if you want a deck of Card widgets, but now you can also use the SwipingDeck widget which uses templating to accept a deck of anything that extends the Widget class. Here are a few usage examples:

SwipingDeck<Card> deckOfCards = SwipingDeck<Card>(...); // A deck of Card widgets, equivalent to the SwipingCardDeck widget
SwipingDeck<Widget> deckOfWidgets = SwipingDeck<Widget>(...); // A deck of Widget objects, the broadest type of deck
SwipingDeck<Container> deckOfContainers = SwipingDeck<Container>(...); // A deck of Container objects, can only include Container widgets or widgets that extend the Container class

Let me know if you have any questions about using this feature, or if you have any other ideas that could make the package better. Thank you again for opening this issue and contributing to open-source projects!