0PricingLogin
Dart Academy · Lesson

if, else if, and else

Run code only when conditions hold.

Run Code Only Sometimes

Sometimes you want code to run only when a condition is met. The if statement is how you make that choice in Dart. 🔀

The Basic if

An if takes a bool in parentheses. When it is true, the block in braces runs; when false, Dart simply skips it.

if (score > 90) {
  print("Great job!");
}

All lessons in this course

  1. Booleans and Comparison Operators
  2. if, else if, and else
  3. Logical Operators and Short-Circuiting
  4. The Ternary and switch Expression
← Back to Dart Academy