If and else
Dart supports if
statements with optional else
statements, as thenext sample shows. Also see conditional expressions.
if (isRaining()) {
you.bringRainCoat();
} else if (isSnowing()) {
you.wearJacket();
} else {
car.putTopDown();
}
Unlike JavaScript, conditions must use boolean values, nothing else. SeeBooleans for more information.