Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class QuizPage extends StatefulWidget {

class _QuizPageState extends State<QuizPage> {
List<Icon> scoreKeeper = [];
// check players score
int score=0;

void checkAnswer(bool userPickedAnswer) {
bool correctAnswer = quizBrain.getCorrectAnswer();
Expand All @@ -48,8 +50,11 @@ class _QuizPageState extends State<QuizPage> {
Alert(
context: context,
title: 'Finished!',
desc: 'You\'ve reached the end of the quiz.',
desc: 'You\'ve reached the end of the quiz. Score: $score / 13',
).show();

// reset score
score=0;

//TODO Step 4 Part C - reset the questionNumber,
quizBrain.reset();
Expand All @@ -61,6 +66,10 @@ class _QuizPageState extends State<QuizPage> {
//TODO: Step 6 - If we've not reached the end, ELSE do the answer checking steps below 👇
else {
if (userPickedAnswer == correctAnswer) {
if(score< 0){
score = 0;
}
score++;
scoreKeeper.add(Icon(
Icons.check,
color: Colors.green,
Expand Down Expand Up @@ -137,9 +146,13 @@ class _QuizPageState extends State<QuizPage> {
),
),
),
Row(
children: scoreKeeper,
)
Flexible(
child: Center(
child: Row(
children: scoreKeeper,
),
),
),
],
);
}
Expand Down