Dart Tutorial

Dart Lesson 1 of 102 2 min read

What Is Dart? An Introduction to the Dart Language

Dart is a typed, object-oriented language from Google used to build mobile, web, desktop and server apps. Learn what it is and why people use it.

On this page

Dart is a programming language created by Google. It was first shown in 2011, and today it is best known as the language behind Flutter, the toolkit used to build apps for Android, iOS, web, Windows, macOS and Linux from one codebase.

You can also use Dart on its own for command-line tools, servers and scripts. This tutorial teaches the language itself, so everything you learn here applies whether or not you go on to Flutter.

What Dart code looks like #

If you have seen Java, C#, JavaScript or Kotlin, Dart will look familiar. Every program starts in a function called main.

void main() {
  var language = 'Dart';
  print('Hello from $language!');
}
Hello from Dart!

Why learn Dart #

  • It is typed, but not noisy. Dart checks types before your program runs, so many bugs are caught while you type. You rarely have to write the types out because Dart infers them.
  • It is null safe. A variable cannot hold null unless you say so. This removes a whole family of crashes. See null safety.
  • It is fast to work in. During development Dart runs on a virtual machine with hot reload, so changes show up in under a second.
  • It is fast to run. For release, Dart compiles to native machine code for phones and desktops, and to JavaScript or WebAssembly for browsers.
  • One language covers the whole app. The same Dart code can run in your mobile app, your website and your backend.

How Dart runs your code #

Dart has two ways of running a program, and you will use both without thinking about it.

ModeWhen it is usedWhat you get
JIT (just-in-time)dart run and Flutter debug buildsQuick start, hot reload, rich debugging
AOT (ahead-of-time)dart compile exe and Flutter release buildsSmall, fast native programs

A short history #

YearWhat happened
2011Dart is announced by Google
2013Dart 1.0 is released
2018Dart 2 adds a sound type system; Flutter 1.0 ships
2021Dart 2.12 introduces sound null safety
2023Dart 3 adds records, patterns and class modifiers

This site teaches Dart 3. Everything shown works on any current stable release.

What you need before starting #

Nothing except a computer and curiosity. Lessons are short and build on each other, so follow them in order the first time through.

Try it yourself #

Press Run on the example above. Change 'Dart' to your own name and run it again. That is all it takes to write and run a Dart program.

Practise in the playground Updated by Santosh Adhikari