Logical Operator in Dart Programming

Logical operators in dart are used when we want to evaluate expressions by putting conditional statements in between them, which ultimately results in a Boolean value.

Logical operators are only applied on Boolean operands.

There are three types of logical operators that are present in Dart. In the table below all of them are mentioned along with their name and the result they produced when they are used on two Boolean operands.

Let's consider two Boolean variables named, x and y, with values true and false respectively.

Consider the table shown below −

&&Logical ANDReturns true if all expressions are truex && y = false
||Logical ORReturns true is any expression is truex || y = true
!Logical NOTReturns compliment of the expression!x = false

Let's make use of all the above mentioned logical operators in a Dart program.


Consider the example shown below −

 Live Demo

void main(){
   var x = true, y = false;
   print("x && y is: ${x && y}");
   print("x || y is: ${x || y}");
   print("!x is: ${!x}");


x && y is: false
x || y is: true
!x is: false

Updated on: 21-May-2021


Kickstart Your Career

Get certified by completing the course

Get Started