AnupKumarPanwar / swipe_cards

Tinder like swipe cards for flutter.
https://pub.dev/packages/swipe_cards
BSD 3-Clause "New" or "Revised" License
52 stars 47 forks source link

Thank you for this package but Match card stops working after re-initializing MatchMachine #33

Open maxiggle opened 8 months ago

maxiggle commented 8 months ago

I want to say a big thank you for creating this package. I love your package and it is helpful

I wanted to make sure that cards on the stack did not finish from the stack, so I re-initialized like below:

  void initState() {
    super.initState();
    _init();
  }

  void _init() {
    for (int i = 0; i < matches.length; i++) {
      _swipeItems.add(
        SwipeItem(
          content: MatchData(
              image: matches[i].image,
              userName: matches[i].userName,
              age: matches[i].age,
              gender: matches[i].gender,
              role: matches[i].role,
              travelingTo: matches[i].travelingTo,
              opt1: matches[i].opt1,
              opt2: matches[i].opt2,
              isVerified: matches[i].isVerified,
              numberOfTipsGiven: matches[i].numberOfTipsGiven,
              startMonth: matches[i].startMonth,
              endMonth: matches[i].endMonth,
              travelYear: matches[i].travelYear,
              travelAideRating: matches[i].travelAideRating,
              selectedOpt: matches[i].selectedOpt),
        ),
      );
    }
    _matchEngine = MatchEngine(swipeItems: _swipeItems);
    Provider.of<RequestProvider>(context, listen: false).matchEngine =
        _matchEngine!;
  }```

but methods from the matchmachine which I believe is the Controller, stops working unexpectedly

``` widget.matchEngine.currentItem?.nope();

How do I resolve this?