if, else if, else let you branch code paths based on a condition. You'll run into this constantly with things like login status, form validation, pricing rules, and user role permissions.
dart
void main() {
int score = 82;
if (score >= 90) {
print('Grade A');
} else if (score >= 80) {
print('Grade B');
} else if (score >= 60) {
print('Grade C');
} else {
print('Try again with a better study plan.');
}
}Dart checks conditions from top to bottom. As soon as score >= 80 is true, it outputs Grade B and doesn't check any further conditions.
You should see
Grade B