What does continue do inside a loop?
continue skips the rest of the current iteration and jumps to the next one. break exits the loop entirely.
Direct program execution with if/else, switch, and loops
Passing the Quiz & Exercises is mandatory to earn FX and proceed. If you fail, try again to gain the required FX, then the Proceed button will become available.
You can read this lesson publicly. Sign in to unlock exercises, quiz, and FX progress tracking.
Having trouble? AI is here to help
Ask context-aware questions about this lesson. Free plan: 5 questions/day. Upgrade to Premium for higher daily limits.
Use the AI button at the bottom of the screen
Control flow determines which code runs and how many times. It is how programs make decisions and repeat operations.
1// ── if / else if / else ──2int temp = 28;34if (temp > 35) {5print('🔥 Very hot');6} else if (temp > 25) {7print('☀️ Warm'); // This runs8} else {9print('❄️ Cold');10}1112// ── switch Statement ──13String day = 'Monday';14switch (day) {15case 'Saturday':16case 'Sunday':17print('Weekend!');18break;19case 'Monday':20print('Back to work'); // This runs21break;22default:23print('Weekday');24}
1// ── for Loop ──2for (int i = 0; i < 3; i++) {3print(i); // 0, 1, 24}56// ── for-in (iterate collection) ──7List<String> colors = ['red', 'green', 'blue'];8for (String color in colors) {9print(color); // red, green, blue10}1112// ── while Loop ──13int count = 0;14while (count < 3) {15print('count: $count');16count++;17}1819// ── break and continue ──20for (int i = 0; i < 10; i++) {21if (i == 3) continue; // skip 322if (i == 6) break; // stop at 623print(i); // 0, 1, 2, 4, 524}
In Flutter, for-in loops (or map) build widget lists dynamically: ```dart children: items.map((item) => ListTile(title: Text(item))).toList(), ```
Control flow powers many daily UI decisions:
The goal is predictable logic paths so users always see correct UI for every state.
In Dart 3, control flow received its biggest upgrade with Switch Expressions. Instead of traditional switch statements requiring case, break;, and boilerplate return statements, switch expressions evaluate patterns and return values directly using =>:
// Modern Dart 3 Switch Expression:
final statusText = switch (statusCode) {
200 => 'OK',
400 => 'Bad Request',
401 || 403 => 'Unauthorized Access', // Logical OR pattern
>= 500 && <= 599 => 'Server Outage', // Relational pattern
_ => 'Unknown Response', // Wildcard default
};
You can also match and destructure complex data structures directly inside an if statement:
final pair = (404, 'Page not found');
if (pair case (404, final message)) {
print('Caught 404 error: \$message');
}
Direct program execution with if/else, switch, and loops. Dart is the language behind Flutter, and clear Dart code makes your Flutter UI easier to maintain.
Build confidence with basics first; speed comes later.
Prefer readable names, explicit intent, and async/await over deeply nested callbacks.
When Dart basics are weak, state bugs, null crashes, and async confusion increase quickly.
continue skips the rest of the current iteration and jumps to the next one. break exits the loop entirely.
break exits the switch statement. Without break, execution "falls through" to the next case.
for-in is the idiomatic Dart way to iterate collections. It is cleaner than index-based for loops for simple iteration.
do-while checks the condition after the body runs. This guarantees the body executes at least once.
Something seems incorrect, unclear, or missing? Let us know.
FlutterCraft editorial lessons are reviewed by experienced Flutter developers and updated to stay aligned with modern Flutter and Dart best practices.
Reference docs: Flutter Documentation, Dart Language Tour, and official package documentation where relevant.
Sign in to continue with exercises and quiz for this lesson.
Sign In to Continue