I am using flip_card package for flipping the cards in my quiz application. I have a next button to change the question and answer on both sides of card. But the problem is if the card is on answer side(back side), clicking the next button shows the answer of next question. I want to automatically reverse the card with next button click, if it is in answer side.
pub dev link : flip_card
github link : flip_card Github
class Practice extends GetView {
final ShowcaseController cardController = Get.put(ShowcaseController());
final PracticeController practiceController = Get.put(PracticeController());
final subjectName;
Practice({this.subjectName});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blue[100],
body: Center(
child: Obx(
() =>
//Flip_card Code
FlipCard(
direction: FlipDirection.HORIZONTAL,
front: Container(
color: Colors.white,
child: Text(cardController.cards[practiceController.cardIndex.toInt()]["question"]),
),
back: Container(
color: Colors.red,
child: Text(cardController.cards[practiceController.cardIndex.toInt()]["answer"]),
),
),
),
),
floatingActionButton: FloatingActionButton(
child: Text("Next"),
onPressed: () {
practiceController.cardIndex++;
},
),
);
}
}