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 Equality and Relational Operators

Dart provides the functionality of checking the relationship between the values or values within the variables.

These operators return the resultant value as Boolean, i.e., either ‘true’ or ‘false’.

Some important points to remember

  1. All these equality and relational operators are binary operators.
  2. The general structure of these equality and relational operator is similar to other binary operators :

                         Operand operator Operand
         Operands refer to the values and Operator is the symbol that instructs the             compiler about the function to be performed on the operands.

  1. In the case of strings, they are said to be equal only if these two strings contain the same character sequence.

List of Equality and Relational Operator

Let us consider the following table that contains the list of all the equality and relational operators in Dart.

For the following table, Consider A = 35, and B = 20

Operator

Operator Name

Operator Description

Example

> 

Greater than

This operator checks which operand is bigger and gives the result as a Boolean expression.

( A > B ) will return False

< 

Lesser than

This operator checks which operand is smaller and gives the result as a Boolean expression.

( A < B ) will return True

>=

Greater than or equal to

This operator checks which operand is greater or equal to each other and gives the result as a Boolean expression.

( A >= B ) will return False

<=

Lesser than or equal to

This operator checks which operand is less than or equal to each other and gives the result as a Boolean expression.

( A <= B ) will return True

==

Equality

This operator checks whether the operands are equal to each other or not and gives the result as a Boolean expression.

( A == B ) will return False

!=

Not equal

This operator checks whether the operands are not equal to each other or not and gives the result as a Boolean expression.

( A != B ) will return True

Consider the following code in the Dart language that explains the concept of Equality and Relational Operator

Program

void main( )

{

  int a = 25, b = 30 ;




  // Greater than Relational Operator

  var res1 = a > b ;

  print( ' \n Is a greater than b ? ' ) ;

  print ( res1 ) ;




  // Lesser than Relational Operator

  var res2 = a < b ;

  print( ' \n Is a lesser than b ? ' ) ;

  print ( res2 ) ;




  // Greater than or equal to Relational Operator

  var res3 = a >= b ;

  print( ' \n Is a greater than equal to b ? ' ) ;

  print ( res3 ) ;




  // Lesser than or equal to Relational Operator

  var res4 = a <= b ;

  print( ' \n Is a lesser than equal to b ? ' ) ;

  print ( res4 ) ;




  // Equal to Operator

  var res5 = a == b ;

  print( ' \n Is a equal to b ? ' ) ;

  print ( res5 ) ;




  // Not equal to Operator

  var res6 = a != b ;

  print( ' \n Is a not equal to b ? ' ) ;

  print ( res6 ) ;

}

Output

Is a greater than b ?

false


Is a lesser than b ?

true


Is a greater than equal to b ?

false


Is a lesser than equal to b ?

true


Is a equal to b?

false


Is a not equal to b ?

true