Question #219MediumDart Basics

What are all the different operators in flutter ?

#flutter

Answer

Overview

Dart provides a comprehensive set of operators. Here is a complete reference of all operator types available in Dart/Flutter.


Complete Operator Reference

Arithmetic

dart
+   // Addition
-   // Subtraction
*   // Multiplication
/   // Division (returns double)
~/  // Integer division
%   // Modulo
-e  // Unary negation

Increment / Decrement

dart
++x  // Pre-increment
x++  // Post-increment
--x  // Pre-decrement
x--  // Post-decrement

Relational / Comparison

dart
==  // Equal
!=  // Not equal
>   // Greater than
<   // Less than
>=  // Greater than or equal
<=  // Less than or equal

Logical

dart
&&  // Logical AND
||  // Logical OR
!   // Logical NOT

Bitwise

dart
&   // Bitwise AND
|   // Bitwise OR
^   // Bitwise XOR
~   // Bitwise NOT
<<  // Left shift
>>  // Right shift
>>> // Unsigned right shift (Dart 2.14+)

Assignment

dart
=    // Assign
+=   // Add and assign
-=   // Subtract and assign
*=   // Multiply and assign
/=   // Divide and assign
~/=  // Integer divide and assign
%=   // Modulo and assign
&=   // Bitwise AND and assign
|=   // Bitwise OR and assign
^=   // Bitwise XOR and assign
<<=  // Left shift and assign
>>=  // Right shift and assign
??=  // Assign if null

Type Test

dart
is   // Type check (returns bool)
is!  // Negative type check
as   // Type cast

Null-Aware

dart
?.   // Conditional member access
??   // Null coalescing (or default)
??=  // Assign if null
!    // Null assertion (force unwrap)
...? // Null-aware spread

Collection / Cascade

dart
[]   // List/Map subscript access
[]=  // Subscript assign
..   // Cascade (chain calls on same object)
?..  // Null-aware cascade
...  // Spread operator in collections

Conditional

dart
? :  // Ternary: condition ? ifTrue : ifFalse

Quick Examples

dart
// Type
value is String      // true/false
value as String      // cast

// Cascade
Paint()..color = Colors.red..strokeWidth = 2;

// Null-aware cascade
user?..name = 'Alice'..save();

// Spread
final list = [...list1, ...list2];

// Subscript
final first = list[0];
map['key'] = 'value';

Most Used in Flutter:

text
?.
,
text
??
,
text
!
,
text
==
,
text
!=
,
text
&&
,
text
||
,
text
??=
,
text
...
(spread),
text
..
(cascade).