onChildQuizDone method

void onChildQuizDone(
  1. FoQuizDoneEvent event
)

Implementation

void onChildQuizDone(FoQuizDoneEvent event) {
  /// See if there is another selected option with a child quiz after this one
  /// If there is one, show that, otherwise emit done
  final index = model.options.indexOf(
      model.options.firstWhere((option) => option.child == currentChildQuiz));

  try {
    final nextOptionWithChildQuiz =
        model.options.skip(index + 1).firstWhere((option) => option.selected);

    currentChildQuiz = nextOptionWithChildQuiz.child;
    if (currentChildQuiz == null) {
      doneController.add(model);
    }
    // ignore: avoid_catching_errors, empty_catches
  } on StateError {}
}