Open topex-psy opened 4 months ago
As of swipe_cards: ^2.0.0+1
, there is no direct method to handle this. But you can achieve this with the following approach.
Check addNewCards(); // Add this line on the 5th last card you add.
_swipeItems.add(SwipeItem(
content: Content(text: _names[i], color: _colors[i]),
likeAction: () {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Liked ${_names[i]}"),
duration: Duration(milliseconds: 500),
));
addNewCards(); // Add this line on the 5th last card you add.
},
nopeAction: () {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Nope ${_names[i]}"),
duration: Duration(milliseconds: 500),
));
addNewCards(); // Add this line on the 5th last card you add.
},
superlikeAction: () {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Superliked ${_names[i]}"),
duration: Duration(milliseconds: 500),
));
addNewCards(); // Add this line on the 5th last card you add.
},
onSlideUpdate: (SlideRegion? region) async {
print("Region $region");
}));
As of
swipe_cards: ^2.0.0+1
, there is no direct method to handle this. But you can achieve this with the following approach.Check
addNewCards(); // Add this line on the 5th last card you add.
_swipeItems.add(SwipeItem( content: Content(text: _names[i], color: _colors[i]), likeAction: () { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text("Liked ${_names[i]}"), duration: Duration(milliseconds: 500), )); addNewCards(); // Add this line on the 5th last card you add. }, nopeAction: () { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text("Nope ${_names[i]}"), duration: Duration(milliseconds: 500), )); addNewCards(); // Add this line on the 5th last card you add. }, superlikeAction: () { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text("Superliked ${_names[i]}"), duration: Duration(milliseconds: 500), )); addNewCards(); // Add this line on the 5th last card you add. }, onSlideUpdate: (SlideRegion? region) async { print("Region $region"); }));
Thank you.
But what does the addNewCards()
function looks like?
Is it just adding new items to _swipeItems
list variable?
Should we recreate the MatchEngine
?
Can you give more complete example?
You can just add new items to _swipeItems
and call setState()
This is my need: After swiping, when there are only 5 cards left, I need to insert/append more cards
How to achieve this?