Table of Contents
Get Started
Dart Installation
Dartpad
Local Setup
Comments in Dart
Variables
Numbers in Dart
Double in Dart
Integer in Dart
String in Dart
Operation on String
String Interpolation
Boolean in Dart
Operator
Decision Making
Switch in Dart
Ternary Operator
Loops
List in Dart
Operation on List
Map in Dart
Boolean in Dart #
Let’s understand this using life example. In school life we have seen True/False kind of question, where we have to tell weather the statement is true or false.
Boolean came from there only. Boolean is used of that kind of purpose only. Whenever you need answer in True/False then we use boolean.
Boolean data can have at most two possible values.
- true
- false
In dart
boolean
is refer asbool
How to declare and assign value of bool #
void main(){
bool aa = true; // Assign value while declaring the variable
bool yy ; // declare a variable
yy = false; // let's assign some value to variable
print(ans);
print(yy);
aa = false; // update value of bool type
print(aa);
}
Real Example #
void main(){
int a = 10;
int b = 20;
boole answer = a < b; // Yes, A is less than B
print(answer); // We will get true in console
}