Common operators in Dart
1. Arithmetic Operators
+
: Addition-
: Subtraction*
: Multiplication/
: Division (returns a double)~/
: Integer division (returns an int)%
: Modulus (remainder)
2. Equality and Relational Operators
==
: Equal to!=
: Not equal to>
: Greater than<
: Less than>=
: Greater than or equal to<=
: Less than or equal to
3. Type Test Operators
is
: Checks if the object is of a specified typeis!
: Checks if the object is not of a specified type
4. Assignment Operators
=
: Simple assignment+=
: Add and assign-=
: Subtract and assign*=
: Multiply and assign/=
: Divide and assign~/=
: Integer divide and assign%=
: Modulus and assign
5. Logical Operators
&&
: Logical AND||
: Logical OR!
: Logical NOT
6. Bitwise and Shift Operators
&
: Bitwise AND|
: Bitwise OR^
: Bitwise XOR~
: Bitwise NOT<<
: Left shift>>
: Right shift
7. Conditional (Ternary) Operator
condition ? expr1 : expr2
: If the condition is true, evaluatesexpr1
; otherwise, evaluatesexpr2
.
8. Null-aware Operators
??
: Provides a default value if the expression on the left is null??=
: Assigns a value to a variable only if that variable is null?.
: Calls a method or accesses a property only if the object is not null
These operators help perform various operations in Dart for arithmetic, comparisons, logical evaluations, and more.