Dart Operators: Complete Guide for Flutter Developers
Operators are special symbols in Dart that perform operations on variables and values. They help developers perform calculations, compare values, make decisions, handle null values, and write cleaner code. Understanding operators is essential for every Flutter developer because they are used in almost every application.
1. Arithmetic Operators
Arithmetic operators are used to perform mathematical calculations.
| Operator | Description | Example |
|---|---|---|
| + | Addition | a + b |
| - | Subtraction | a - b |
| * | Multiplication | a * b |
| / | Division | a / b |
| ~/ | Integer Division | a ~/ b |
| % | Modulus | a % b |
void main() {
int a = 10;
int b = 3;
print(a + b);
print(a - b);
print(a * b);
print(a / b);
print(a ~/ b);
print(a % b);
}
2. Increment and Decrement Operators
These operators increase or decrease a value by one.
int count = 5; count++; print(count); count--; print(count);
3. Relational Operators
Relational operators compare two values and return a boolean result.
| Operator | Description |
|---|---|
| == | Equal To |
| != | Not Equal To |
| > | Greater Than |
| < | Less Than |
| >= | Greater Than or Equal To |
| <= | Less Than or Equal To |
print(10 > 5); print(10 == 5); print(10 != 5);
4. Logical Operators
Logical operators are used to combine multiple conditions.
| Operator | Description |
|---|---|
| && | Logical AND |
| || | Logical OR |
| ! | Logical NOT |
bool isLoggedIn = true; bool isAdmin = false; print(isLoggedIn && isAdmin); print(isLoggedIn || isAdmin); print(!isAdmin);
5. Assignment Operators
Assignment operators assign values to variables.
- =
- +=
- -=
- *=
- /=
- ~/=
- %=
int number = 10; number += 5; number -= 2; number *= 3; print(number);
6. Type Test Operators
Type test operators check the type of an object.
dynamic value = "Flutter"; print(value is String); print(value is! int);
is → Returns true if the object belongs to the specified type.
is! → Returns true if the object does not belong to the specified type.
7. Type Cast Operator
The as operator converts an object into a specific type.
dynamic data = "Flutter"; String name = data as String; print(name);
8. Conditional Operators
Ternary Operator (? :)
A shorter alternative to if-else statements.
int age = 20;
String result =
age >= 18 ? "Adult" : "Minor";
print(result);
Null Coalescing Operator (??)
String? name; print(name ?? "Guest");
9. Null-Aware Operators
- ?. → Access property if object is not null.
- ?? → Return default value if null.
- ??= → Assign value only if null.
- ! → Tell Dart value is not null.
name ??= "Sachin";
10. Cascade Operator (..)
The cascade operator allows multiple operations on the same object without repeating its name.
var person = Person() ..name = "Sachin" ..age = 25 ..showInfo();
11. Spread Operators
Spread Operator (...)
var list1 = [1, 2, 3]; var list2 = [...list1, 4, 5]; print(list2);
Null-Aware Spread (...?)
List? numbers; var result = [...?numbers];
Why Dart Operators Matter in Flutter
- Improve code readability
- Reduce boilerplate code
- Handle null safety efficiently
- Make Flutter widgets more optimized
- Help write clean and maintainable applications
Interview-Focused Operators
- ??
- ?.
- !
- ??=
- is
- is!
- as
- ..
- ...
- ...?
- ? :
- ~/
Conclusion
Operators are one of the most important building blocks of Dart programming. From arithmetic calculations to null safety and type checking, operators help developers write concise, readable, and efficient code. Mastering these operators will improve your Flutter development skills and help you write production-ready applications with confidence.

