setCurrentStepQuestionFromApi method
void
setCurrentStepQuestionFromApi(
- String? questionFromApi
)
Implementation
void setCurrentStepQuestionFromApi(String? questionFromApi) {
_currentQuestionIndex = 0;
//additive security to avoid out of range errors
//if incoherence, return
if (_currentStepIndex > steps.length - 1) {
return;
}
try {
int foundIndex = steps[_currentStepIndex].displayableQuestions.indexWhere((e) => e.questionKey == questionFromApi);
if (foundIndex == -1) {
return;
}
_currentQuestionIndex = foundIndex;
} catch (e, s) {
debugPrint('❌ Impossible to find the saved quiz question: $e \n trace: $s');
}
}