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 Miscellaneous Operators

Apart from the operators we studied so far, Dart provides some more operators which are as follows :

  1. Conditional Operator
  2. Cascade Notations

Conditional Operators

These are the operators that help in evaluating the expression that otherwise would have required if-else statements.

Syntax:

Condition ? expr1 : expr2

Condition here refers to a test expression that may evaluate to true or false. If it evaluates to true then expr1 is executed and if it evaluates to false, then expr2 is executed.

Program

Consider the following code in Dart that explains Conditional Operator

import 'dart:io';


void main( ) {
  print( ' Enter your age : ' ) ;
  int? age = int.parse( stdin.readLineSync ( ) ! ) ;


  var res = age >= 18
      ? " You are eligible to vote. "
      : " You are not eligible to vote. " ;


  print( res ) ;
}

Output:

Enter your age : 
20
You are eligible to vote.

Dart Cascade Operators

The Cascade notation Operators (..) is used to evaluate a series of operation on the same object. It is an identical as the method chaining that avoids several of steps, and we don't need store results in temporary variables.