Booleans

on Saturday, 18th of July, 2020

bool is the Dart type that represents a boolean value. It can be true or false.

// assign directly
bool isPortland = true;
bool isWinter = true;

// You can combine booleans with &&, ||, and other symbols
// if isPortland is true AND isWinter is true
bool isRaining = isPortland && isWinter;

if (isRaining) {
  print("Grab an umbrella!");
} else {
  print("The sun is shining!");
}

// prints
"Grab an umbrella!"


Join thousands of Flutter developers.

Sign up for infrequent updates about Flutter and Dart.

You can get all this content and more in one place. Check out my new book Flutter in Action