Dart Tutorial

Dart Lesson 2 of 102 2 min read

How to Install Dart on Windows, macOS and Linux

Step-by-step guide to installing the Dart SDK on Windows, macOS and Linux, checking the version, and setting up VS Code.

On this page

You can start learning in the browser with DartPad, but sooner or later you will want Dart on your own machine. That means installing the Dart SDK, which contains the dart command, the compilers and the core libraries.

If you already installed Flutter, you have Dart. Flutter ships with its own copy of the SDK. Run dart --version to confirm.

Windows #

The easiest route is the Chocolatey package manager. Open PowerShell as administrator and run:

choco install dart-sdk

Close and reopen the terminal so the new PATH is picked up.

macOS #

Use Homebrew:

brew tap dart-lang/dart
brew install dart

Linux #

On Debian and Ubuntu, add Google’s package repository and then install with apt:

sudo apt-get update && sudo apt-get install apt-transport-https
wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub \
  | sudo gpg --dearmor -o /usr/share/keyrings/dart.gpg
echo 'deb [signed-by=/usr/share/keyrings/dart.gpg arch=amd64] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main' \
  | sudo tee /etc/apt/sources.list.d/dart_stable.list
sudo apt-get update && sudo apt-get install dart

For other distributions, or if these commands have changed, follow the official page at dart.dev/get-dart.

Check that it worked #

dart --version

You should see a line that starts with Dart SDK version: 3. followed by your platform. If the terminal says the command is not found, the SDK’s bin folder is not on your PATH yet. Reopen the terminal, or add the folder by hand.

Set up an editor #

Any text editor works, but these two give you autocomplete, error highlighting and a debugger:

  • Visual Studio Code: install the Dart extension from the Extensions panel.
  • IntelliJ IDEA or Android Studio: install the Dart plugin from Settings, then Plugins.

Create and run a project #

The dart create command builds a small project with the right folder layout.

dart create hello_dart
cd hello_dart
dart run
Hello world: 42!

The code you just ran lives in bin/hello_dart.dart. The pubspec.yaml file next to it describes the project and its dependencies. You will meet it again in packages.

Commands you will use every day #

CommandWhat it does
dart runRuns the program in the current project
dart run file.dartRuns a single file
dart format .Formats your code in the standard style
dart analyzeReports errors and warnings without running
dart testRuns your tests
dart compile exe bin/app.dartBuilds a standalone program

Try it yourself #

Install Dart, create a project called my_first_app, and run it. Then open bin/my_first_app.dart and change the message it prints.

Practise in the playground Updated by Santosh Adhikari