Dart Introduction
What is Dart?
Dart is a programming language made by Google.
Google showed Dart for the first time in 2011.
Dart 1.0 came out in 2013, and Dart 3 came out in 2023.
Dart is free and open source.
Dart is used for:
- Mobile apps for Android and iOS, with Flutter
- Web apps
- Desktop apps for Windows, macOS and Linux
- Command-line tools and servers
Dart and Flutter
Flutter is a toolkit from Google for building apps.
With Flutter, you write one app, and it runs on phones, in the browser and on the desktop.
All Flutter apps are written in Dart.
This is the main reason why many people learn Dart.
Note: This tutorial teaches the Dart language itself.
Everything you learn here is what you need before you start with Flutter.
Why Use Dart?
- Dart is easy to read, and the syntax looks like JavaScript, Java and C#
- Dart has null safety: the compiler stops you from using a missing value (
null) by mistake - Dart has a strong type system, so many errors are found before the program runs
- Dart can compile to fast native code, to JavaScript and to WebAssembly
- Dart has a large collection of free packages on pub.dev
Dart Compared to Other Languages
If you know another language, this table shows how Dart is similar:
| Dart has | Like |
|---|---|
| Curly brackets and semicolons | JavaScript, Java, C# |
| Classes, inheritance and interfaces | Java, C#, Kotlin |
Null safety with ? and ! | Kotlin, Swift, TypeScript |
async and await | JavaScript, C#, Python |
Type inference with var | C#, Kotlin, Swift |
Dart Syntax
Here is a small Dart program:
Example
void main() {
var name = 'Dart';
var year = 2011;
print('Hello, $name!');
print('$name was first shown in $year.');
}
Try it Yourself »
Result:
Hello, Dart!
Dart was first shown in 2011.
You will learn what each line does in the next chapters.