0
0
Fluttermobile~5 mins

Control flow (if, for, while, switch) in Flutter - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does an if statement do in Flutter?
An if statement checks a condition and runs code only if that condition is true. It helps the app decide what to do next.
Click to reveal answer
beginner
How does a for loop work in Flutter?
A for loop repeats a block of code a set number of times. It’s like telling the app to do something again and again.
Click to reveal answer
intermediate
What is the purpose of a while loop?
A while loop keeps running code as long as a condition stays true. It’s useful when you don’t know how many times you need to repeat beforehand.
Click to reveal answer
intermediate
Explain the switch statement in Flutter.
A switch statement checks a value and runs code for the matching case. It’s like choosing a path based on different options.
Click to reveal answer
beginner
Why is control flow important in mobile apps?
Control flow lets apps make decisions and repeat tasks. It helps apps respond to user actions and show the right screens or data.
Click to reveal answer
What will this if statement do if the condition is false?<br>
if (isLoggedIn) {
  showHomePage();
}
ARestart the app
BShow the home page
CShow an error
DDo nothing
How many times will this for loop run?<br>
for (int i = 0; i < 3; i++) {
  print(i);
}
A3 times
B2 times
C1 time
DInfinite times
What happens if the while loop condition is never true?
AThe loop runs once
BThe loop does not run at all
CThe loop runs forever
DThe app crashes
Which statement best describes a switch?
ARepeats code forever
BChecks if a condition is true
CChooses code to run based on a value
DStops the app
Why use control flow in a mobile app?
ATo make decisions and repeat tasks
BTo change the app icon
CTo speed up the internet
DTo store user data
Describe how an if statement controls app behavior.
Think about how the app decides to do something only sometimes.
You got /3 concepts.
    Explain the difference between a for loop and a while loop.
    One counts how many times, the other checks a condition each time.
    You got /4 concepts.