Dart Logical Operators
Overview
Logical Operators are used to logically combine two or more Boolean expressions. A Boolean expression is an expression that evaluates to either true or false. Logical operators allow you to perform logical operations on Boolean values or logical expressions.
Dart Logical Operators
The Dart programming language provides the following logical operators::
Operator Symbol | Operation Name | Description |
&& | AND Operator | The logical AND operator is used to combine two conditions and if both conditions are true, it will return true. |
|| | OR Operator | The logical OR operator is used to combine two conditions and if even one of the conditions is true, it will return true. |
| | NOT operator | The logical NOT operator is used to reverse the result of the condition. |
Example
Let’s understand the operators with a sample Dart program.
/* * Logical Operators Dart Program * Dart Tutorials - www.TestingDocs.com */ void main() { int x = 7; int y = 9; // AND operator // checks if both x is greater than 5 and y is less than 10 bool result1 = (x > 5) && (y < 10); print(result1); // OR operator // checks if either x is less than 0 or y is equal to 9 bool result2 = ( x < 0) || (y == 9); print(result2); // NOT operator // checks if x is not equal to 7 bool result3 = !( x == 7); print(result3); }
—
More information on Dart Programming language: