BrunoJurkovic/tcard

Card getting stuck after calling controller.back()

Opened this issue · 4 comments

        TCard(
                controller: tCardController,
                onEnd: () {
                  Navigator.of(context).pop();
                },
                onForward: (i, info) {
                  if (cardIsFront != false) {

                      tCardController.back();
                
            ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                content: Text("Please Flip the Card"),
                duration: Duration(
                  milliseconds: 500,
                )));
          } else {
            if (info.direction.index == 1) {
              ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                  content: Text("Correct"),
                  duration: Duration(
                    milliseconds: 500,
                  )));
            } else {
              ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                  content: Text("Incorrect"),
                  duration: Duration(
                    milliseconds: 500,
                  )));
            }
          }

          cardIsFront = null;
        },
        size: Size(400, 600),
        cards: widget.deck.flashCards!
            .map((e) => QuizCard(
                  key: Key("${widget.deck.flashCards!.indexOf(e)}"),
                  flashCard: e,
                  onFlip: (value) {
                    cardIsFront = !value;
                  },
                ))
            .toList()),`

So when I swipe the card to left , the card automatically returns to its initial position ,however if I touch the card in the middle of the "back to initial position animation", the card gets stuck and when I try to move it ,it tries to rotate

2021-08-20 12-08-51

It looks like a bug, i will try to fix it.

Is this issue still persistent?

Noticed the same behavior as well when I was changing the card size constrain for testing

in lib/src/animations.dart

/// Card Sizes
class CardSizes {
  static Size front(BoxConstraints constraints) {
   
    return Size(constraints.maxWidth , constraints.maxHeight * 0.95);
  }

  static Size middle(BoxConstraints constraints) {
    return Size(constraints.maxWidth * 0.85, constraints.maxHeight * 0.9);
  }

  static Size back(BoxConstraints constraints) {
    return Size(constraints.maxWidth * 0.8, constraints.maxHeight * .9);
  }
}

can confirm that the bug is still persistent