【发布时间】:2021-11-12 10:39:10
【问题描述】:
我正在使用 flip_card 包来翻转我的测验应用程序中的卡片。我有一个下一个按钮来更改卡片两面的问题和答案。 但问题是如果卡片在答案面(背面),单击下一步按钮会显示下一个问题的答案。如果卡片在应答侧,我想通过单击下一步按钮自动反转卡片。
发布开发链接:flip_card
github 链接: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++;
},
),
);
}
}
【问题讨论】:
标签: flutter dart dart-pub flutter-getx