initializeData method
- dynamic data
Initialize the data from the JSON file in the provider
We load the choices and assetPath from JSON file to shuffle it.
Then we load :
- choices, choicesPath that represents the data and its image
- questions corresponds to the question image
- answerData that correspond the data and image answer for each question to the provider
Then, we load the lives and question from the JSON file.
Finally, we set the isInitialized to true, to prevent multiple data initialization
Implementation
void initializeData(dynamic data) {
answerData = (data["answer"] as List)
.map((dynamic e) => e as Map<String, dynamic>)
.toList();
isInitialized = true;
lives = data["lives"];
question = data["question"];
questions = data["questionAssetPath"].cast<String>();
choicesPath = data["choicePath"].cast<String>();
choices = data["choices"].cast<String>();
}