Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL SQLITE MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING HTML & CSS BASH RUST DART PLAYWRIGHT TOOLS MATH SHEETS POWER BI

Dart Tutorial

Dart HOME Dart Intro Dart Get Started Dart Syntax Dart Output Dart Comments Dart Variables Dart final and const Dart Data Types Dart Numbers Dart Strings Dart String Interpolation Dart String Methods Dart Booleans Dart Type Conversion Dart Null Safety Dart late Dart Operators Dart Arithmetic Dart Assignment Dart Comparison Dart Logical Dart Type Test Dart Null Operators Dart Cascade Dart If...Else Dart Switch Dart While Loop Dart For Loop Dart Break/Continue

Dart Collections

Dart Lists Dart Access List Items Dart Change List Items Dart Loop Lists Dart List Methods Dart Sets Dart Maps Dart Access Map Items Dart Loop Maps Dart Collection if/for Dart Spread Operator

Dart Functions

Dart Functions Dart Parameters Dart Named Parameters Dart Return Values Dart Arrow Functions Dart Anonymous Functions Dart Closures Dart Scope Dart Recursion

Dart Classes

Dart OOP Dart Classes/Objects Dart Constructors Dart Named Constructors Dart Factory Constructors Dart Getters and Setters Dart Static Members Dart Inheritance Dart Abstract Classes Dart Interfaces Dart Mixins Dart Extension Methods Dart Enums Dart Generics

Dart 3 Features

Dart Records Dart Patterns Dart Switch Expressions Dart Sealed Classes Dart Class Modifiers

Dart Errors

Dart Exceptions Dart Custom Exceptions

Dart Async

Dart Async Intro Dart Futures Dart async/await Dart Streams Dart Isolates

Dart Libraries

Dart Imports Dart Packages Dart Math Dart Dates Dart JSON Dart RegExp Dart User Input Dart Files Dart Testing

Dart Examples

Dart Examples Dart Exercises


Dart Operators


Share

Dart Operators

Operators are symbols that do something with values and variables.

In the example below, we use the + operator to add two numbers:

Example

void main() {
  int x = 100 + 50;
  print(x);
}
Try it Yourself »

Result:

150

The values on each side of an operator are called operands.

The operands can be values, variables, or a mix of both:

Example

void main() {
  int sum1 = 100 + 50;
  int sum2 = sum1 + 250;
  int sum3 = sum2 + sum2;

  print(sum1);
  print(sum2);
  print(sum3);
}
Try it Yourself »

Result:

150
400
800

Operator Groups

The Dart operators can be divided into these groups:

GroupOperatorsUsed for
Arithmetic operators+ - * / ~/ % ++ --Math with numbers
Assignment operators= += -= *= /= ~/= %= ??=Giving values to variables
Comparison operators== != > < >= <=Comparing two values
Logical operators&& || !Combining true and false values
Type test operatorsis is! asChecking and changing the type of a value
Null-aware operators?? ??= ?. ?.. ?[]Working with values that can be null
Cascade notation.. ?..Doing many things with the same object

Each group has its own chapter.

Click a group name in the table to read more.



Operator Precedence

Operator precedence is the order in which Dart calculates the operators in an expression.

Like in math, multiplication is done before addition:

Example

void main() {
  print(2 + 3 * 4);
}
Try it Yourself »

Result:

14

Dart calculates 3 * 4 first, and then adds 2.

Use parentheses () to calculate a part first:

Example

void main() {
  print((2 + 3) * 4);
}
Try it Yourself »

Result:

20

Tip: Parentheses also make your code easier to read, even when they are not needed.


Operators and Types

What an operator does depends on the type of the values.

With strings, + joins two strings, and * repeats a string:

Example

void main() {
  String firstName = 'John';
  String lastName = 'Doe';

  print(firstName + ' ' + lastName);
  print('Ha' * 3);
}
Try it Yourself »

Result:

John Doe
HaHaHa

Comparison operators always give a bool value, true or false:

Example

void main() {
  int age = 20;
  bool isAdult = age >= 18;
  print(isAdult);
}
Try it Yourself »

Result:

true


Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by W3Schools. All Rights Reserved. W3Schools is Powered by W3.CSS.