Dart Installation — Complete Setup Guide for All Platforms
In this tutorial, you will learn about Dart Installation. We cover key concepts, practical examples, and best practices to help you master this topic.
Installing the Dart SDK gives you the Dart compiler, VM, package manager (pub), linter, formatter, and testing tools needed to write and run Dart applications across all major operating systems.
What You Will Learn
- Installing the Dart SDK on Windows, macOS, and Linux
- Verifying the installation with command-line tools
- Setting up VS Code and Android Studio for Dart development
- Configuring Flutter (which includes Dart)
- Managing multiple Dart SDK versions with FVM
- Troubleshooting common installation issues
Why It Matters
A correct SDK installation is the foundation for all Dart development. Errors at this stage waste hours of debugging later. Because Dart has multiple installation methods and dependencies on system tools like Git and platform SDKs, it is important to follow the right steps for your operating system and use case. This guide covers every platform and both standalone Dart installation and Flutter-bundled installation.
Real-World Use
Every DodaTech developer workstation has the Dart SDK installed via the Flutter bundle. The continuous integration pipeline uses the Dart SDK via a Docker image with the official Dart base image. Both approaches share the same tools and produce identical results.
Learning Path
flowchart LR A[What Is Dart?] --> B[Installation\nYou are here] B --> C[Dart Variables] style B fill:#f90,color:#fff
Installing on Windows
The recommended method on Windows is to use the Flutter SDK, which includes Dart. Alternatively, you can install Dart standalone using Chocolatey or the official installer.
Method 1: Flutter SDK (Recommended)
Download the Flutter SDK from flutter.dev, extract it to a folder like C:\flutter, and add C:\flutter\bin to your PATH environment variable. Flutter includes the Dart SDK automatically:
# Verify that both flutter and dart are available
flutter --version
dart --version
Method 2: Chocolatey
choco install dart-sdk
After installation, verify the Dart SDK in a new terminal:
dart --version
Output example: Dart SDK version: 3.3.0 (stable) (Tue Jan 23 13:28:37 2024 +0000) on "windows_x64"
Installing on macOS
On macOS, you can install Dart via Homebrew, the Flutter bundle, or download the SDK manually.
Method 1: Homebrew
brew tap dart-lang/dart
brew install dart
Method 2: Flutter SDK
git clone https://github.com/flutter/flutter.git -b stable --depth 1
export PATH="$PATH:`pwd`/flutter/bin"
Add the Flutter bin directory to your shell profile (.zshrc or .bash_profile) for permanent access:
echo 'export PATH="$PATH:~/flutter/bin"' >> ~/.zshrc
source ~/.zshrc
Verify Installation
dart --version
which dart
Output example: /usr/local/bin/dart
Installing on Linux
On Debian-based distributions, use the official Dart APT Repository:
# Add the Dart stable repository
sudo apt-get update
sudo apt-get install apt-transport-https
sudo sh -c 'wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
sudo sh -c 'wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'
# Install Dart
sudo apt-get update
sudo apt-get install dart
# Add Dart to PATH
echo 'export PATH="$PATH:/usr/lib/dart/bin"' >> ~/.profile
source ~/.profile
On other distributions, download the Dart SDK tarball from dart.dev and extract it:
wget https://storage.googleapis.com/dart-archive/channels/stable/release/3.3.0/sdk/dartsdk-linux-x64-release.zip
unzip dartsdk-linux-x64-release.zip
export PATH="$PATH:$PWD/dart-sdk/bin"
Verifying the Installation
After installation, run these commands to verify everything is working:
dart --version
dart analyze --help
dart format --help
dart pub --help
Create a test file and run it:
// hello.dart
void main() {
print('Dart SDK is working correctly!');
print('Version: ${DateTime.now().year}');
}
dart run hello.dart
Output:
Dart SDK is working correctly!
Version: 2026
Setting Up VS Code
Install the Dart extension from the VS Code marketplace. This extension provides:
- Syntax highlighting and code completion
- IntelliSense with type information
- Code formatting on save
- Debugger integration with breakpoints
- Test runner integration
Add these settings to your VS Code settings.json:
{
"dart.checkForUpdates": true,
"dart.autoFormatOnSave": true,
"dart.openDevTools": "flutter",
"[dart]": {
"editor.tabSize": 2,
"editor.rulers": [80, 120]
}
}
Create a new Dart file, type main and press Tab to generate the void main() snippet. The extension compiles and runs your code with Ctrl+F5.
Setting Up Android Studio
Android Studio supports Dart through the Dart plugin:
- Open Android Studio and go to Settings > Plugins
- Search for "Dart" and install the official Dart plugin
- Go to Settings > Languages & Frameworks > Dart
- Set "Dart SDK path" to the directory where Dart is installed
- Disable "Only enable Dart for the project with Dart support" to use Dart outside Flutter projects
The Dart plugin provides the same features as the VS Code extension plus Flutter widget inspector and performance tooling.
Managing Multiple SDK Versions
When working on multiple projects that require different Dart versions, use FVM (Flutter Version Management):
# Install FVM
dart pub global activate fvm
# Install a specific Dart/Flutter version
fvm install 3.3.0
fvm install 3.10.0
# Set version per project
fvm use 3.3.0 --project
# List installed versions
fvm list
# Set global default
fvm global 3.10.0
FVM stores each SDK version in a cache folder and switches between them by updating symlinks in the project directory.
Using Dart with Flutter
If you installed Flutter instead of standalone Dart, the Dart SDK is inside the Flutter SDK at flutter/bin/cache/dart-sdk. Flutter creates a flutter/bin/dart shim that forwards to the bundled Dart SDK:
# These are equivalent when Flutter is installed
flutter/bin/dart --version
dart --version
The Flutter bundle is recommended for new users because it includes Dart and ensures compatibility between Flutter and Dart versions.
Troubleshooting
dart: command not found: The Dart SDK bin directory is not in your PATH. Add export PATH="$PATH:/path/to/dart-sdk/bin" to your shell profile and restart the terminal.
Error: Unable to pub get: Network connectivity issue. Check internet access, proxy settings, and firewall rules. Use dart pub get --offline if packages are cached.
The current Dart SDK version is X, but Y is required: The project specifies a Dart SDK constraint in pubspec.yaml that does not match your installed version. Update the constraint or change your Dart version with FVM.
Dart does not support null safety in this version: You are using an older Dart SDK (before 2.12). Upgrade to Dart 3.x with dart upgrade or reinstall the latest SDK.
VS Code shows "No Dart SDK found": Ensure the Dart extension has the correct SDK path. Open Command Palette, run "Dart: Change SDK Path", and point to your Dart SDK directory.
Common Mistakes
Installing both standalone Dart and Flutter: If Flutter is on PATH before standalone Dart, the Flutter-bundled Dart will be used. This is fine, but ensure only one is on PATH to avoid version confusion.
Not restarting the terminal after installation: PATH changes take effect only in new terminal sessions. Run
source ~/.zshrcor open a new terminal after installation.Forgetting VS Code Dart extension: The core Dart functionality (syntax highlighting, run, debug) requires the extension. Without it, Dart files are treated as plain text.
Using incompatible Dart and Flutter versions: Some Dart language features require specific Flutter versions. Use
flutter doctorto check compatibility and runflutter upgradeto synchronize versions.Not configuring Android Studio Dart path: Android Studio does not auto-detect the Dart SDK. The Dart plugin must be manually configured with the correct SDK path.
Practice Questions
- What is the difference between installing Dart standalone versus through Flutter?
- Why does the Dart SDK need to be on your PATH environment variable?
- How would you switch between Dart 3.3.0 and Dart 3.10.0 on the same machine?
- What does the VS Code Dart extension provide beyond syntax highlighting?
- Challenge: Set up a new Dart project from scratch using
dart create, configure it for null safety, add thehttppackage from pub.dev, and run the generated test file.
Mini Project
Create a dart_tooling project that demonstrates your Dart development environment works correctly:
- Initialize the project with
dart create - Write a program that prints the Dart version, operating system, and current working directory
- Format the code with
dart format - Run the analyzer with
dart analyze - Run the provided test file
FAQ
What is Next
With Dart installed, you are ready to write your first Dart code. Proceed to Dart Variables and Data Types to learn about types, var, final, and const. Then continue with Control Flow in Dart for conditionals and loops.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro