Dart Tutorial

Dart Tutorial Single-Page Application Architecture Dart Features Dart Installation Guide Dart Basic Program Dart Syntax Dart Keywords Dart Variables Dart Comments Dart Standard Input Output Dart Important Concepts

Data Types

Built-in Data Types Numbers Strings Booleans Lists Sets Maps Runes and Graphemes Symbols Enumerations Constants Queues

Other data types

Objects Future and stream Iterable Miscellaneous types

OPERATORS

Precedence and associativity Arithmetic operators Equality and Relational operators Type Test Operators Assignment Operators Logical Operators Bitwise and Shift Operators Miscellaneous operators

Control Flow Statements

Introduction If statement If-else statement If-else-if statement Loops Switch and case Dart Break And Continue Assert In Dart

FUNCTIONS

Dart function Types of Functions Anonymous function main( ) function Lexical scope and closure Recursion Common Collection Methods

Object Oriented Concepts

Dart Object-Oriented Concepts Dart Classes Dart Constructors Dart This Keyword Dart Super Keyword Static Members Method Overriding Dart Interfaces Inheritance Dart Abstract Classes Dart Builder Classes Dart Callable Classes

Dart Type System

Dart Type System Dart Soundness Dart Type Inference

MISCELLANEOUS

Dart Isolates Dart Typedef Dart Metadata Dart Packages Dart Generics Dart Generators Dart Concurrency Dart Unit Testing Dart Html Dom Dart URIs Dart Extends, With and Implements Keywords Dart Optional Parameters Rust Vs Dart C++ vs Dart Golang Vs Dart Dart Basics Exception Handling

Dart Logical Operators

Logical operators are the operators that combine two or more conditions, and accordingly return a Boolean value : true or false.

Assume the value of variable A is 25 and B is 40.

OperatorDescriptionExample
&&And - The operator returns true if and only if all the expressions return true.(A < 10 && B > 10) is False.
||OR - The operator returns true if at least one of the expressions return true.(A > 10 || B > 10) is True.
!NOT - The operator returns the inverse of the expression’s result. For E.g.: !(17 > 5) returns false!(A < 10) is True.

AND and OR Operators ( && and || )

The && operator returns true if and only if both the conditions return true. If either of them is false, the result is also false.

The || operator returns true if any one of the expressions returns true. It returns false if and only if both conditions are false.

XYX && Y     X || Y        !X
00001
01011
10010
11110

Program

Consider the following code in Dart that explains logical operator,

void main( )
{
    int a = 25 ;
    int b = 15 ;
 
    // Using And Operator ( && )
    // where both conditions are true
    bool c = a > 10 && b > 10 ;
    print( c ) ;


     // Using And Operator ( && )
    // where both conditions are false
    bool d = a > 50 && b < 10 ;
    print( d ) ;
  
    // Using Or Operator ( || )
    // where only one condition is true
    bool e = a > 10 || b < 10 ;
    print( e ) ;
  
    // Using Or Operator ( || )
    // where both conditions are false
    bool f = a > 50 || b < 10 ;
    print( f ) ;  
 
    // Using Not Operator ( ! )
    bool g = !( a > 10 ) ;
    print( g ) ;
}

Output

 true
 false
 true
 false
 false