Tsallaka zuwa abun ciki
Justice Tech School

Dart If and Else

if runs code when a condition is true. else if and else add more branches. The ternary operator cond ? a : b is a short form.

Example
void main() {
  var score = 72;
  if (score >= 85) print("Distinction");
  else if (score >= 70) print("Pass");
  else print("Retake");
  print(score >= 50 ? "ok" : "low");
}

Exercise

Second branch.

if (a) {}  if (b) {}

Quiz Test

What is cond ? a : b?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.