You are on page 1of 6

1.

Variable Initialization: At the start, various variables and lists are established to manage

the current question and the overall set of questions. The integer curQ is used to track the

current question. Four lists of maps (questionData, hardQ, midQ, and easyQ) are then

defined. Each map represents an individual question, which can include attributes like the

question title, the possible answers, and the correct answer. questionData is a master list

containing all the questions, whereas hardQ, midQ, and easyQ store the questions based

on their difficulty levels.

2. Lifecycle Method - initState(): This is a specific method used in Flutter, and it's the first

method to run when the widget is created, happening just once, right after the constructor.
3. Data Fetching - fetchQuestionData(): This asynchronous function is critical as it retrieves

question data from a Firestore collection - a type of NoSQL database provided by

Firebase. After the data has been fetched, the questions are added to the questionData list
4. Functionality Methods: The functions nextQuestion(), addToHardQ(), addToMidQ(), and

addToEasyQ() make up the core functionality of the app. nextQuestion() serves to cycle to the

next question in the questionData list. If the list is empty, it remains inactive. The other three

functions (addToHardQ(), addToMidQ(), addToEasyQ()) move the current question to the

respective difficulty list and then remove it from the questionData list. They also reset curQ (the

current question index) to 0 and start a timer.


4. Timer Methods: Functions startTimer(), startMidTimer(), and startEasyTimer() initiate

timers that run for different durations (10 seconds, 1 minute, and 2 minutes, respectively).

Once a timer ends, it checks if there are any questions left in the difficulty list (hard,

medium, easy). If there are, it moves the first question back to the questionData list and

removes it from the difficulty list.

You might also like