The purpose of the Dart Boolean data type is to determine the true or false value of a given statement. The two Boolean type values are true and false, which are both compile-time constants. In Dart, true or false cannot be specified using the numerical values 1 or 0. The Boolean value is represented by the bool keyword. The following is the syntax for declaring a Boolean variable.

Syntax

				
					bool var_name = true;    
OR    
bool var_name = false;  
				
			

Example

				
					void main() {  
bool check;  
check = 20>10;  
print("The statement is = ${check}");  
}  
				
			

Output

				
					true
				
			

Explanation

The bool variable check, which will be used to validate the provided expression, has been declared. We printed the result when the expression 20>12 returned true.

Share this Doc

Dart Boolean

Or copy link

Explore Topic