Dart Introduction

What Dart is, its relationship to Flutter, installing it or using DartPad, and hello world.

What is Dart?

Dart is an open-source, object-oriented, statically-typed programming language developed by Google, first released in 2011 and substantially reshaped since — modern Dart (2.x and 3.x) bears little resemblance to its earliest versions. It's designed to be easy to learn, compile either to native machine code or JavaScript, and to support fast, hot-reloadable development cycles.

Dart
void main() {
  print('Hello, Dart!');
}

Dart and Flutter

Dart's defining use case today is Flutter, Google's UI toolkit for building natively-compiled applications for mobile, web, desktop and embedded devices from a single codebase. Flutter chose Dart specifically because it compiles ahead-of-time (AOT) to fast native code for release builds, while also supporting a just-in-time (JIT) compiler during development that enables hot reload — seeing UI changes reflected in a running app in under a second, without losing app state. It's worth being precise about the relationship: Dart is the language; Flutter is a UI framework written in Dart, similar to how JavaScript relates to React. You can write plain Dart (CLI tools, backend scripts, packages) without ever touching Flutter, and this track focuses on the language itself.

Why use Dart?

  • One codebase, many platforms — combined with Flutter, the same Dart code ships to iOS, Android, web, Windows, macOS and Linux.
  • Sound null safety — the type system distinguishes nullable and non-nullable types at compile time, eliminating a huge class of null-reference crashes (covered in depth in the next page).
  • Both AOT and JIT compilation — JIT compilation gives Flutter's famous hot reload during development; AOT compilation gives fast startup and predictable performance in production release builds.
  • Familiar, approachable syntax — Dart's class- and curly-brace-based syntax reads comfortably to anyone coming from Java, C#, JavaScript or Kotlin.
  • A single language across the whole app — UI, business logic, and even some backend code (via Dart's server-side capabilities) can share one language and often shared model code.

Installing Dart

The Dart SDK is included automatically when you install Flutter, but can also be installed standalone if you only need the language (e.g., for a CLI tool or backend service, no Flutter involved):

Bash
# macOS (Homebrew)
brew tap dart-lang/dart
brew install dart

# Windows (Chocolatey)
choco install dart-sdk
Bash
dart --version   # e.g. Dart SDK version: 3.4.0

For quick experimentation with no install at all, DartPad (dartpad.dev) runs Dart directly in the browser — a good way to try snippets from this track without setting up a project.

Your first program

Bash
dart create hello_dart
cd hello_dart
dart run
Dart
// bin/hello_dart.dart (generated by `dart create`)
void main(List<String> arguments) {
  print('Hello world!');
}

For a single quick script, you can also just run a file directly:

Bash
dart run hello.dart

Real-world example

Google itself uses Flutter/Dart for parts of Google Pay and Google Ads' mobile apps; other companies shipping major production Flutter apps include Alibaba (Xianyu), BMW, and eBay Motors — chosen largely for the ability to maintain one Dart codebase instead of separate native iOS (Swift) and Android (Kotlin) codebases.

Common mistakes

  • Assuming "Dart" and "Flutter" are interchangeable terms — Dart is the language; Flutter is a UI framework built with it, and this distinction matters when discussing what you're actually debugging.
  • Skipping past null safety early on and reaching for ! reflexively — it's a first-class part of the type system, covered properly on the next page, not a minor detail.
  • Not realizing Dart can be used entirely outside Flutter — for CLI tools, scripts and backend servers — when only a plain language feature (not a widget) is actually needed.

Interview questions

Q: What is the relationship between Dart and Flutter? Dart is the general-purpose programming language; Flutter is Google's UI toolkit, written in Dart, for building cross-platform apps from one codebase. You can write Dart without Flutter (CLI tools, scripts, backend code), but Flutter itself requires Dart.

Q: Why did Flutter choose Dart instead of an existing language like JavaScript? Dart supports both JIT compilation (enabling Flutter's hot reload during development, where UI changes appear near-instantly without losing app state) and AOT compilation to native machine code (giving fast startup and predictable performance in production) — a combination not available from JavaScript engines at the time, and Dart's static typing also helps catch errors earlier in large app codebases.