Booleans
Let’s go over the boolean data type in Dart.
We'll cover the following
True & false
Dart’s bool
type represents boolean values. Only two objects have type bool
, the boolean literals true
and false
.
In the code snippet below, we are declaring a variable b1
of type bool
and assigning it an initial value of true
.
main() {bool b1 = true;print(b1);}
Syntax
The basic syntax for declaring a variable of type bool
is as follows.
bool variableName = Boolean Literal
This is all you need to know regarding bool
for now. You will see more if its use when we discuss operators and conditional statements in later chapters.
main() {bool greater;greater=5>3;print(greater);}
Create a free account to access the full course.
Learn to code, grow your skills, and succeed in your tech interview
By signing up, you agree to Educative's Terms of Service and Privacy Policy