🚈 Control Flow
Review conditional statements, loops, and assertions
Conditional Statements
control-flow.dart
String color = 'blue';
if (color == 'blue') {
//
} else if (color == 'green') {
//
} else {
// default
}
// One liner
if (color == 'red') print('hello red!');
Loops
control-flow.dart
for (var i = 0; i < 5; i++) {
print(i);
// break;
// continue;
}
int i = 0;
while (i < 5) {
print(i);
i++;
}
i = 0;
do {
print(i);
} while (i < 5);
Assertions
control-flow.dart
// Assert
var txt = 'good';
assert(txt != 'bad');