Installing Dart SDK – Overview
Before you start coding in Dart, you need to install the Dart SDK (Software Development Kit). The Dart SDK includes the Dart VM, core libraries, development tools like dart and dartfmt, and the package manager pub. This guide will walk you through installing Dart on Windows, macOS, and Linux, and then verifying the installation with a simple 'Hello World' program.
Prerequisites
- A computer running Windows (7 or later), macOS (10.15+), or a modern Linux distribution.
- Administrator/sudo access (for system‑wide installation).
- Internet connection to download the SDK.
- (Optional) A code editor like VS Code or IntelliJ IDEA for a better development experience.
Method 1: Installing Dart via Official Installer (Windows & macOS)
The easiest way to install Dart on Windows and macOS is by using the official installer from the Dart website.
Windows Installation
- Visit the Dart SDK archive page.
- Download the latest stable Windows installer (e.g.,
dart-sdk-3.x.x-windows-x64.zip).
- Download the latest stable Windows installer (e.g.,
- Extract the ZIP file to a folder, for example
C:\dart-sdk.
- Extract the ZIP file to a folder, for example
- Add the SDK
bindirectory to your system PATH:
- Add the SDK
- Open System Properties → Environment Variables.
- Under 'System variables', find
Path, click Edit, then New.
- Under 'System variables', find
- Add
C:\dart-sdk\binand click OK.
- Add
- Open a new Command Prompt and verify the installation by running
dart --version.
- Open a new Command Prompt and verify the installation by running
macOS Installation
- Download the macOS installer from the Dart SDK archive (choose the
.pkgfile).
- Download the macOS installer from the Dart SDK archive (choose the
- Open the downloaded
.pkgfile and follow the on‑screen instructions.
- Open the downloaded
- The installer automatically adds Dart to your PATH.
- Open Terminal and verify with
dart --version.
- Open Terminal and verify with
Method 2: Installing via Package Manager (Recommended for Linux & macOS)
Using a package manager simplifies updates and dependency management.
macOS with Homebrew
Linux (Debian/Ubuntu) with apt
After installation, you may need to add Dart to your PATH. For Debian/Ubuntu, the SDK is usually installed in /usr/lib/dart/bin. Add it to your shell profile:
Verifying Installation
Open a terminal (or command prompt) and run:
You should see output similar to Dart SDK version: 3.x.x (stable). If the command is not found, double‑check that the SDK bin directory is in your PATH.
Your First Dart Program
Create a file named hello.dart with the following content:
Run it using the Dart VM:
If everything is set up correctly, you'll see Hello, Dart! printed in the console.
Setting Up an Editor
While you can write Dart code in any text editor, using an IDE with Dart support greatly improves productivity. Here's how to set up two popular editors:
Visual Studio Code
- Download and install VS Code.
- Open VS Code and go to the Extensions view (Ctrl+Shift+X).
- Search for 'Dart' and install the official Dart extension by Dart Code.
- Create a new folder for your project, then create a
hello.dartfile.
- Create a new folder for your project, then create a
- You can now run the program by opening the file and pressing F5 (or selecting Run → Start Debugging).
IntelliJ IDEA / Android Studio
- Install IntelliJ IDEA Community Edition (or Android Studio).
- Launch the IDE and go to File → Settings → Plugins (or IntelliJ IDEA → Preferences on macOS).
- Search for 'Dart' and install the Dart plugin.
- Restart the IDE.
- Create a new Dart project (File → New → Project → Dart).
- Write your code and click the green Run button.
Troubleshooting Common Issues
- 'dart' is not recognized as an internal or external command – The SDK
binfolder is not in your PATH. Re‑check the PATH variable and restart your terminal.
- 'dart' is not recognized as an internal or external command – The SDK
- Permission denied on Linux – If you installed via the Debian package, you might need to run
sudofor certain operations, but normal user commands should work after PATH is set correctly.
- Permission denied on Linux – If you installed via the Debian package, you might need to run
- Firewall blocking downloads – Ensure your network allows connections to Google's servers (for the apt repository) or the Dart website.
Next Steps
Now that Dart is installed, you can explore the language fundamentals:
- Learn basic syntax in the Dart Introduction
- Practice with variables and data types
- Try writing simple programs using functions and control flow
- Explore the official Dart documentation