Installation #
Before you can write a single line of Dart, you need to make sure your environment is ready. The Dart SDK is a single package that contains the compiler, runtime, package manager (dart pub), and formatter — all in one installation. This article walks you through the installation process from start to finish until you can run your first Dart program, covering the three major operating systems: Windows, macOS, and Linux, along with editor configuration that will accompany you throughout your learning journey.
Understanding the Dart SDK #
The Dart SDK is more than just an interpreter. Understanding what you’re installing will make troubleshooting much easier when something doesn’t work as expected.
When you install the Dart SDK, you get several binaries you can use directly from the terminal:
| Binary | Purpose |
|---|---|
dart | Main entry point — runs, compiles, formats, and analyzes code |
dart run | Runs .dart files directly |
dart compile | Compiles to native executable, JavaScript, or snapshot |
dart pub | Package manager for managing dependencies |
dart analyze | Static analyzer — catches bugs before runtime |
dart format | Auto-formatter based on the Dart style guide |
dart test | Runs the test suite |
All these binaries live in the bin/ folder inside the Dart SDK directory. That’s why the “add to PATH” step shows up in every installation method — without a correct PATH, the terminal has no idea where to look for these binaries.
flowchart LR
A[Dart SDK] --> B[dart binary]
B --> C[dart run]
B --> D[dart compile]
B --> E[dart pub]
B --> F[dart analyze]
B --> G[dart format]
B --> H[dart test]Installing on Windows #
Windows offers two installation paths with different characters: a GUI installer for users who prefer a visual approach, and Chocolatey for those already comfortable working in the terminal. Both produce identical installations — the difference is only in the method and the installation experience.
Using the Official Installer #
The most straightforward approach with no extra dependencies. A good fit if this is your first installation on the machine.
1. Download the Dart SDK
Open dart.dev/get-dart and pick the Windows tab. Dart offers two architecture choices: x64 for almost all modern computers, and ia32 for 32-bit systems, which are now very rare. If in doubt, choose x64.
You can also choose a channel:
| Channel | Description | Best for |
|---|---|---|
| Stable | Official, tested releases | Learning and production |
| Beta | Features that are almost stable | Trying out the newest features |
| Dev | Bleeding edge, may be unstable | Dart contributors |
Use Stable for learning purposes.
2. Run the installer
Open the downloaded .exe file. The installation wizard will ask for a destination directory — the default is usually C:\Program Files\Dart\dart-sdk. Leave it as is unless you have a specific reason to change it.
Make sure the “Add Dart to the system PATH” option is checked during installation. If you skip this, you’ll need to add the PATH manually after installation finishes.
3. Verify in Command Prompt
Open a new Command Prompt or PowerShell window (it must be new — terminals that were already open before installation haven’t loaded the new PATH), then run:
dart --version
Expected output:
Dart SDK version: 3.x.x (stable) (...)
Using Chocolatey #
Chocolatey is a package manager for Windows that lets you install and update software from the command line. If you don’t have Chocolatey yet, this is a good time to install it — you’ll use it often for other developer needs.
1. Install Chocolatey
Open PowerShell as Administrator (right-click → “Run as Administrator”), then run:
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Close PowerShell and open a new one after installation finishes.
2. Install the Dart SDK
choco install dart-sdk
Chocolatey will download and install the Dart SDK automatically, including PATH configuration.
3. Updating Dart in the future
The advantage of using Chocolatey is easy updates:
choco upgrade dart-sdk
4. Verify
dart --version
Manual PATH Configuration (If Needed) #
If you skipped the PATH option during installation or used the manual extraction method, add the PATH manually:
- Open System Properties → Environment Variables
- In the “System variables” section, find the
Pathvariable and click Edit - Click New and add the path to the Dart SDK’s
binfolder, e.g.C:\Program Files\Dart\dart-sdk\bin - Click OK, close all dialogs, then open a new terminal
flowchart TD
A[Open System Properties] --> B[Environment Variables]
B --> C[Select the Path variable]
C --> D[Edit → New]
D --> E[Add the path to dart-sdk/bin]
E --> F[OK and restart the terminal]
F --> G{dart --version works?}
G -- Yes --> H[✓ Installation complete]
G -- No --> I[Check the path you entered]
I --> DInstalling on macOS #
macOS offers the smoothest installation experience thanks to Homebrew — the package manager that has become the de facto standard in the macOS developer ecosystem. However, the manual installer is still available if you prefer full control over the installation location.
Using Homebrew #
Homebrew is the most recommended way to install Dart on macOS, because managing updates is very easy and integrates with the typical macOS developer workflow.
1. Install Homebrew (if you don’t have it)
Open Terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This process requires an internet connection and takes a few minutes. Homebrew will ask for your admin password to complete the installation.
2. Install the Dart SDK
brew tap dart-lang/dart
brew install dart
The brew tap command adds Dart’s official repository to Homebrew’s list of sources, so you get Dart directly from the Dart team — not from a third-party repository.
3. Verify
dart --version
4. Updating Dart in the future
brew upgrade dart
Or update all Homebrew packages at once:
brew upgrade
Using the Installer from the Official Site #
If you don’t use Homebrew or want to place the Dart SDK in a specific location:
1. Download the Dart SDK
Visit dart.dev/get-dart, select the macOS tab, choose your architecture (x64 for Intel Macs, arm64 for Apple Silicon M1/M2/M3).
If you’re using a Mac with an Apple Silicon chip (M1, M2, M3), make sure to pickarm64for optimal performance. Thex64version still runs through Rosetta 2, but native performance is better witharm64.
2. Extract and move to the right directory
# Extract the archive
unzip dart-sdk-macos-x64-release.zip
# Move to /usr/local (requires sudo)
sudo mv dart-sdk /usr/local/dart-sdk
3. Add to PATH
Edit your shell configuration file. If you’re using zsh (the default on macOS Catalina and later):
echo 'export PATH="$PATH:/usr/local/dart-sdk/bin"' >> ~/.zshrc
source ~/.zshrc
If you’re using bash:
echo 'export PATH="$PATH:/usr/local/dart-sdk/bin"' >> ~/.bashrc
source ~/.bashrc
4. Verify
dart --version
Installing on Linux #
Linux is the most flexible platform for installing Dart. Three methods are available depending on your distribution: APT for Debian/Ubuntu-based systems, manual installation for other distributions, and snap as a universal alternative.
Using APT (Debian/Ubuntu) #
This method adds Dart’s official repository to the APT system, so you get Dart updates together with your regular system updates.
1. Add the Dart repository
# Install the required dependencies
sudo apt-get update
sudo apt-get install apt-transport-https curl gnupg
# Add Google's signing key
curl https://dl-ssl.google.com/linux/linux_signing_key.pub \
| sudo gpg --dearmor -o /usr/share/keyrings/dart.gpg
# Add the Dart repository
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
2. Install the Dart SDK
sudo apt-get update
sudo apt-get install dart
3. Add Dart to PATH
Dart installed via APT is usually stored at /usr/lib/dart/bin. Add it to PATH:
echo 'export PATH="$PATH:/usr/lib/dart/bin"' >> ~/.bashrc
source ~/.bashrc
If you’re using zsh:
echo 'export PATH="$PATH:/usr/lib/dart/bin"' >> ~/.zshrc
source ~/.zshrc
4. Verify
dart --version
Using Snap #
Snap is a universal package manager available on many modern Linux distributions. If your system already has snapd:
sudo snap install dart --classic
The --classic flag is required because Dart needs full filesystem access, which the standard Snap sandbox doesn’t allow.
Manual Installation (All Distributions) #
For Linux distributions that don’t use APT or snap — like Arch Linux, Fedora, openSUSE, or Alpine:
1. Download the Dart SDK
# Replace VERSION with the latest Dart version, e.g. 3.4.0
VERSION=3.4.0
curl -O https://storage.googleapis.com/dart-archive/channels/stable/release/${VERSION}/sdk/dartsdk-linux-x64-release.zip
Or download directly from dart.dev/get-dart and transfer it to your Linux server.
2. Extract and place the SDK
# Extract
unzip dartsdk-linux-x64-release.zip
# Move to /usr/local
sudo mv dart-sdk /usr/local/dart-sdk
3. Add to PATH permanently
echo 'export PATH="$PATH:/usr/local/dart-sdk/bin"' >> ~/.bashrc
source ~/.bashrc
4. Verify
dart --version
Comparison of Linux Installation Methods #
| Method | Distro | Automatic updates | Ease |
|---|---|---|---|
| APT | Debian, Ubuntu, Mint | ✓ apt upgrade | Easy |
| Snap | Ubuntu, Fedora, and others | ✓ Automatic | Easy |
| Manual | All distributions | ✗ Manual | Moderate |
Verifying Your Environment #
After a successful installation on any operating system, do a full verification before moving on to editor setup.
Check the Dart Version #
dart --version
Expected output (the version may differ):
Dart SDK version: 3.4.0 (stable) (Mon May 20 16:00:00 2024 +0000) on "macos_arm64"
Check Full Environment Info #
dart info
This command shows more detailed information: platform, SDK version, and installation location. Useful for troubleshooting and when reporting bugs.
Create and Run Your First Program #
The best way to make sure your installation works perfectly is to run real Dart code. Create a new file called hello.dart:
void main() {
print('Hello, Dart!');
// Check the runtime version
print('Platform: ${Platform.operatingSystem}');
}
Run it with:
dart run hello.dart
If Hello, Dart! appears in the terminal, your installation is working perfectly.
Initializing a Dart Project #
For a more structured project, use Dart’s built-in project template:
# Create a new console application project
dart create hello_project
# Enter the project directory
cd hello_project
# See the structure that was created
The generated project structure:
hello_project/
├── bin/
│ └── hello_project.dart ← entry point
├── lib/
│ └── hello_project.dart ← main library
├── test/
│ └── hello_project_test.dart
├── pubspec.yaml ← project config & dependencies
├── pubspec.lock
├── analysis_options.yaml ← analyzer configuration
└── README.md
Run the project:
dart run
Editor Setup #
A Dart SDK installed in the terminal is enough to run code, but for a comfortable coding experience, you need an editor integrated with Dart. The two most popular editors with the best Dart support are Visual Studio Code and IntelliJ IDEA.
Visual Studio Code #
VS Code is the most common choice for Dart developers, especially those who also use Flutter. Lightweight, fast, and with a rich extension ecosystem.
1. Install VS Code
Download from code.visualstudio.com and install as usual.
2. Install the Dart extension
Open VS Code, press Ctrl+Shift+X (Windows/Linux) or Cmd+Shift+X (macOS) to open the Extensions panel. Search for “Dart” and install the Dart extension from the publisher Dart Code.
Alternatively, install from the command line:
code --install-extension Dart-Code.dart-code
3. Features that activate right after installing the extension
Once the Dart extension is installed, VS Code immediately supports:
- IntelliSense — autocomplete that understands Dart data types
- Inline errors — errors shown right in the editor, not just at compile time
- Go to definition —
Ctrl+Clickto jump to a function or class definition - Refactoring — rename variables, extract methods, and more
- Dart DevTools — integrated visual debugging
- Format on save — automatically formats code when saving a file
4. Configure format on save (optional but recommended)
Open Settings (Ctrl+,), search for “format on save”, and enable it. This ensures your code always follows the Dart style guide without having to run dart format manually.
Or add it to the .vscode/settings.json file in your project:
{
"[dart]": {
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.selectionHighlight": false,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.suggestSelection": "first",
"editor.tabCompletion": "onlySnippets",
"editor.wordBasedSuggestions": "off"
}
}
IntelliJ IDEA #
IntelliJ IDEA (and Android Studio, which is built on IntelliJ) provides a full IDE experience with more advanced refactoring features. A good fit if you’re already used to the JetBrains ecosystem.
1. Install the Dart plugin
Open IntelliJ IDEA, go to Preferences (macOS) or Settings (Windows/Linux) → Plugins. Search for “Dart” in the Marketplace and click Install.
2. Configure the SDK path
After the plugin is installed, open Preferences → Languages & Frameworks → Dart. Fill in the “Dart SDK path” field with your Dart SDK installation location:
- Windows:
C:\Program Files\Dart\dart-sdk - macOS (Homebrew):
/opt/homebrew/opt/dart/libexec - Linux:
/usr/lib/dartor/usr/local/dart-sdk
3. Verify in the IDE
Open or create a .dart file. If IntelliJ shows syntax highlighting and autocomplete works, the configuration is successful.
Editor Comparison #
| Feature | VS Code + Dart Extension | IntelliJ IDEA + Dart Plugin |
|---|---|---|
| Weight | Lightweight | Heavy |
| Startup time | Fast | Slow |
| IntelliSense | Very good | Very good |
| Refactoring | Good | More complete |
| Debugger | Integrated | Integrated |
| Price | Free | Community (free) / Ultimate (paid) |
| Best for | Most developers | Developers who need a full IDE |
For beginners just learning Dart, VS Code with the Dart extension is the most recommended choice. The setup is quick, the interface is clean, and its features are more than enough from learning all the way to building production applications.
Common Troubleshooting #
Some issues you’re likely to run into after installation, and how to fix them.
dart: command not found
#
This is a PATH problem. The terminal can’t find the dart binary.
# ANTI-PATTERN: panic and reinstall immediately
# Reinstalling won't help if the problem is PATH
# CORRECT: first check whether dart exists on the system
which dart # macOS/Linux
where dart # Windows
# If it's not found, check whether PATH is configured correctly
echo $PATH # macOS/Linux
$env:PATH # Windows PowerShell
If dart exists on the system but is still not found, the terminal you’re using probably hasn’t reloaded its PATH configuration. Close the terminal and open a new one.
Errors when running dart run
#
# ANTI-PATTERN: ignore the error message and just run it again
dart run hello.dart # if it errors, run again hoping the error goes away
# CORRECT: read the error message carefully
dart analyze hello.dart # analyze the code before running
Most errors during dart run are syntax errors that can be detected before execution with dart analyze.
Dart Version Not What You Expected #
# Check the active version
dart --version
# If you're using Homebrew on macOS and the version is old
brew update
brew upgrade dart
# If you're using Chocolatey on Windows
choco upgrade dart-sdk
# If you're using APT on Linux
sudo apt-get update
sudo apt-get upgrade dart
If you have more than one Dart installation on your system (for example, one from the Flutter SDK and a standalone installation), thedartcommand may point to a different version than you expect. Usewhich dart(macOS/Linux) orwhere dart(Windows) to confirm which path is active.
Understanding the Dart SDK vs Flutter SDK #
One important point that often confuses beginners: what’s the relationship between the Dart SDK and the Flutter SDK?
The Flutter SDK already includes the Dart SDK inside it. If you’ve already installed Flutter for mobile/web development, you already have Dart.
Flutter SDK/
├── bin/
│ └── flutter ← Flutter CLI
└── dart-sdk/
└── bin/
└── dart ← Dart bundled with Flutter
However, there’s an important difference in how you use them:
| Scenario | Use |
|---|---|
| Pure Dart learning, CLI tools, server-side | Standalone Dart SDK |
| Flutter development (mobile, web, desktop) | Flutter SDK (Dart included) |
| Both at the same time | Watch your PATH — make sure the active dart matches your needs |
flowchart TD
A{What's your main goal?} -- Learning Dart / server-side / CLI --> B[Install the standalone Dart SDK]
A -- Mobile/web development with Flutter --> C[Install the Flutter SDK]
C --> D[Dart SDK is already included]
B --> E[Dart SDK ready to use]
D --> E
E --> F[dart --version]Summary #
- The Dart SDK is one complete package — it includes
dart run,dart compile,dart pub,dart analyze, anddart formatin a single installation.- Windows: use the official installer from dart.dev or Chocolatey (
choco install dart-sdk). Make sure the PATH option is checked during installation.- macOS: Homebrew is the easiest way —
brew tap dart-lang/dart && brew install dart. Choosearm64for Apple Silicon.- Linux: APT for Debian/Ubuntu (
sudo apt-get install dartafter adding the repository), snap for other distributions, or manual extraction for Arch/Fedora and similar.- PATH is the key — if
dart: command not found, the problem is almost always an unconfigured PATH or a terminal that hasn’t been reloaded.- Always verify the installation with
dart --versionand by running a simple.dartfile before moving on to editor setup.- Editor: VS Code with the Dart extension is the most recommended choice for beginners — lightweight, free, and feature-complete.
- The Flutter SDK already includes Dart — if you’ve installed Flutter, you don’t need to install the Dart SDK separately.
- Regular updates matter because Dart releases new versions regularly with performance improvements and new language features.