answerChoice method

bool? answerChoice(
  1. int choiceIndex
)

Resposta por botão (choiceIndex em answers). Devolve true se acertou e avançou, false se errou (segue na mesma), null se ignorada (revelando ou terminou).

Implementation

bool? answerChoice(int choiceIndex) {
  if (done || revealing) return null;
  final question = questions[index];
  final correct = question.correct;
  if (correct == null) return null;
  // Com `correctSet` (EX16), qualquer índice do conjunto serve de primeira.
  final right = question.correctSet.isEmpty
      ? {correct}
      : question.correctSet.toSet();
  if (right.contains(choiceIndex)) {
    index++;
    revealing = false;
    if (!done) _startAt = _lastTick ?? _now();
    return true;
  }
  _markWrong();
  return false;
}