Created
January 20, 2023 15:09
-
-
Save gboliknow/6c204bbfa2d301b255246a0717c81753 to your computer and use it in GitHub Desktop.
Quiz App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class QuizWidget extends StatefulWidget { | |
const QuizWidget({ | |
super.key, | |
required this.quizModel, | |
}); | |
final QuizModel quizModel; | |
@override | |
State<QuizWidget> createState() => _QuizWidgetState(); | |
} | |
class _QuizWidgetState extends State<QuizWidget> { | |
int selected = -1; | |
void toggle(int pageNum) { | |
setState(() { | |
selected = pageNum; | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Column( | |
children: <Widget>[ | |
AppText( | |
fontSize: 16.sp, | |
height: 19.2 / 16, | |
text: widget.quizModel.questionText, | |
color: grey700, | |
weight: FontWeight.w400, | |
textAlign: TextAlign.start, | |
), | |
SizedBox( | |
height: 32.h, | |
), | |
ListView.builder( | |
itemCount: widget.quizModel.options.length, | |
shrinkWrap: true, | |
itemBuilder: (BuildContext context, int index) { | |
return OptionCard( | |
option: widget.quizModel.options[index].optionText, | |
clicked: selected == index, | |
onTap: () { | |
toggle(index); | |
}, | |
); | |
}, | |
), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment