verify method

  1. @override
void verify(
  1. dynamic data
)
override

Verify if the selected selectedAnswer is the correct one.

If the choosen selectedAnswer is not the answer, decrease the number of lives by one. Otherwise, add the actual answer to the _correctAnswers list and choose the next question.

Implementation

@override
void verify(dynamic data) {
  selectedAnswer = data;

  if (selectedAnswer == answer) {
    progress++;
    _answerQueue.removeFirst();
    correctAnswer = true;
  } else {
    lives -= (lives > 0) ? 1 : 0;
    _answerQueue.addLast(_answerQueue.removeFirst());
    correctAnswer = false;
  }

  if (nextQuestion && _answerQueue.isNotEmpty) {
    answer = _answerQueue.first;
    nextQuestion = false;
  }
  selectedAnswer = null;
}