How to Install Dart on Debian Linux

Dart is a programming language developed by Google for building web, server, and mobile applications. Debian’s default repositories do not include Dart, so installation requires adding Google’s official repository. Whether you need to create command-line tools, backend services, or cross-platform apps with Flutter, Dart provides the compiler technology and package management to get you started quickly. By the end of this guide, you will have the Dart SDK installed on Debian, verified with a working test application, and compiled for production deployment.

Dart offers two compilation modes suited to different stages of development. First, Dart Native includes a VM for just-in-time (JIT) compilation during development and an ahead-of-time (AOT) compiler for generating optimized machine code for production. Additionally, Dart Web provides compilers for JavaScript and WebAssembly output, enabling browser-based applications.

Choose Your Dart Release Channel

Google distributes Dart through three release channels. Therefore, choose the channel that matches your development needs before proceeding with installation.

ChannelUpdate FrequencyStabilityBest For
StableEvery 3 monthsProduction-readyMost users, production deployments
BetaMonthlyPreview qualityTesting upcoming features before stable release
DevTwice weeklyExperimentalDevelopers needing latest bug fixes and features

Recommendation: Use the stable channel unless you have a specific reason to test pre-release features. This guide uses the stable channel in examples.

Update Debian Before Installation

Refresh your package lists and upgrade installed packages to ensure your system has the latest security patches and dependencies:

sudo apt update && sudo apt upgrade

Here, apt update downloads the latest package information from configured repositories. Meanwhile, apt upgrade installs newer versions of packages already on your system.

Install Required Packages

Before adding a third-party repository, you need tools to securely download files and verify cryptographic signatures. Most Debian installations include these by default, but minimal installations or containers may lack them:

sudo apt install wget ca-certificates gnupg

Specifically, wget downloads files from HTTPS URLs. In addition, ca-certificates contains root certificates that validate secure connections. Finally, gnupg handles GPG key operations—importing, verifying, and converting keys between formats.

Import Dart GPG Key

APT uses GPG keys to verify that packages come from their claimed source and have not been modified in transit. Download Google’s signing key and convert it from ASCII-armored format to the binary format that APT requires:

wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/dart.gpg

In this command, the -qO- flag downloads the key and outputs it to stdout. Next, gpg --dearmor converts the text-based PGP key to binary format. As a result, storing keys in /usr/share/keyrings/ with a scoped reference in the repository file follows current Debian security best practices—each repository uses only its designated key rather than a global trusted keyring.

Add Dart Repository

Configure the Dart repository using the modern DEB822 .sources format. This format is the default on Debian 13 and fully supported on Debian 12 and 11.

Stable Repository (Recommended)

Add the stable repository for production-ready releases. The command below automatically detects your system architecture:

cat <<EOF | sudo tee /etc/apt/sources.list.d/dart.sources
Types: deb
URIs: https://storage.googleapis.com/download.dartlang.org/linux/debian
Suites: stable
Components: main
Signed-By: /usr/share/keyrings/dart.gpg
Architectures: $(dpkg --print-architecture)
EOF

Beta Repository (Optional)

To use beta releases instead, change the Suites value to testing:

cat <<EOF | sudo tee /etc/apt/sources.list.d/dart.sources
Types: deb
URIs: https://storage.googleapis.com/download.dartlang.org/linux/debian
Suites: testing
Components: main
Signed-By: /usr/share/keyrings/dart.gpg
Architectures: $(dpkg --print-architecture)
EOF

Dev Repository (Optional)

For the latest development builds, use the unstable suite:

cat <<EOF | sudo tee /etc/apt/sources.list.d/dart.sources
Types: deb
URIs: https://storage.googleapis.com/download.dartlang.org/linux/debian
Suites: unstable
Components: main
Signed-By: /usr/share/keyrings/dart.gpg
Architectures: $(dpkg --print-architecture)
EOF

The $(dpkg --print-architecture) command automatically inserts your system’s architecture into the configuration file. Google’s Dart repository supports amd64, arm64, armhf, and riscv64 architectures. If your architecture is not supported, download Dart directly from the SDK archive.

Verify Repository Configuration

Refresh APT’s package cache and confirm that the Dart repository is active before proceeding with installation:

sudo apt update
apt-cache policy dart

Expected output showing the Google repository as the source:

dart:
  Installed: (none)
  Candidate: 3.10.2-1
  Version table:
     3.10.2-1 500
        500 https://storage.googleapis.com/download.dartlang.org/linux/debian stable/main amd64 Packages

This output confirms APT recognizes the Dart package from Google’s repository. Specifically, the Candidate line shows the version available for installation and the 500 priority indicates normal repository priority.

Install Dart SDK

With the repository verified, install the Dart SDK:

sudo apt install dart

After installation, the Dart SDK resides in /usr/lib/dart with the dart command available via /usr/bin/dart. Notably, the SDK includes the Dart VM for running code during development, the dart2js compiler for web deployment, the pub package manager for dependency management, and the dart analyze tool for static code analysis.

Verify Installation

Now, confirm Dart is installed correctly by checking the version:

dart --version

Expected output:

Dart SDK version: 3.10.2 (stable) (Tue Nov 25 11:03:22 2025 -0800) on "linux_x64"

Create a Test Application

Building a sample application confirms that the SDK installed correctly and familiarizes you with Dart’s project structure. Fortunately, Dart’s create command generates starter projects from templates, handling boilerplate setup so you can focus on application logic.

Generate Project Structure

Use dart create with the console template to generate a command-line application:

dart create -t console my_dart_app

Expected output:

Creating my_dart_app using template console...

  .gitignore
  analysis_options.yaml
  CHANGELOG.md
  pubspec.yaml
  README.md
  bin/my_dart_app.dart
  lib/my_dart_app.dart
  test/my_dart_app_test.dart

Running pub get...
  Resolving dependencies...
  Downloading packages...
  Changed 48 dependencies!

Created project my_dart_app in my_dart_app! In order to get started, run the following commands:

  cd my_dart_app
  dart run

The generated project includes:

  • bin/my_dart_app.dart — The main entry point containing the main() function
  • lib/my_dart_app.dart — Library code imported by the main file
  • pubspec.yaml — Package metadata and dependency declarations
  • test/ — Directory for unit tests

Run the Application

Navigate to the project directory and execute the application:

cd my_dart_app
dart run

Expected output:

Hello world: 42!

Modify and Re-run

Edit lib/my_dart_app.dart to change the calculation. For example, divide the result by two:

int calculate() {
  return 6 * 7 ~/ 2;
}

Run the application again to see the updated output:

dart run

Expected output:

Hello world: 21!

Compile for Production

While the Dart VM provides fast iteration during development, production deployments benefit from AOT compilation. Therefore, compile your application to a native executable:

dart compile exe bin/my_dart_app.dart

Expected output:

Generated: /home/user/my_dart_app/bin/my_dart_app.exe

Run the compiled executable and measure execution time:

time bin/my_dart_app.exe

Expected output:

Hello world: 21!

real    0m0.002s
user    0m0.002s
sys     0m0.000s

Here, the time command shows three metrics: real is the wall-clock time, user is CPU time in user mode, and sys is CPU time in kernel mode. Consequently, AOT-compiled Dart executables start nearly instantly compared to JIT execution.

Troubleshooting

GPG Key Import Fails

If the GPG key download fails, you may see an error like:

--2025-01-15 10:30:00--  https://dl-ssl.google.com/linux/linux_signing_key.pub
Resolving dl-ssl.google.com... failed: Temporary failure in name resolution.

First, verify your internet connection:

ping -c 3 google.com

If the ping succeeds, retry the key download. Alternatively, download the key in two steps to isolate potential issues:

wget https://dl-ssl.google.com/linux/linux_signing_key.pub
sudo gpg --dearmor -o /usr/share/keyrings/dart.gpg linux_signing_key.pub
rm linux_signing_key.pub

Verify the key was imported successfully:

ls -la /usr/share/keyrings/dart.gpg

Expected output showing the key file exists:

-rw-r--r-- 1 root root 12775 Dec  2 10:00 /usr/share/keyrings/dart.gpg

Repository Update Errors

If apt update reports signature verification errors, you may see:

Err:1 https://storage.googleapis.com/download.dartlang.org/linux/debian stable InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 1655A0AB68576280

To resolve this, check that the GPG key file exists and has correct permissions:

ls -la /usr/share/keyrings/dart.gpg

Expected output shows the file with read permissions:

-rw-r--r-- 1 root root 12775 Dec  2 10:00 /usr/share/keyrings/dart.gpg

If the file exists but has incorrect permissions, fix them:

sudo chmod 644 /usr/share/keyrings/dart.gpg

If missing entirely, re-import the GPG key using the command from the earlier section, then retry apt update:

sudo apt update

A successful update shows no signature errors for the Dart repository.

Command Not Found After Installation

If running dart --version returns:

bash: dart: command not found

First, verify that Dart is actually installed:

which dart
dpkg -l dart

Expected output when Dart is installed correctly:

/usr/bin/dart
ii  dart           3.10.2-1       amd64        Dart SDK

If which dart returns nothing but dpkg -l dart shows the package is installed, reinstall to fix broken symlinks:

sudo apt reinstall dart

If Dart is not installed at all, run the installation command again:

sudo apt update
sudo apt install dart

Verify the fix by checking the version:

dart --version

Remove Dart

Removing Dart deletes the SDK but does not remove your projects or downloaded packages. Review the optional cleanup commands below if you want to remove all Dart-related data from your system.

Uninstall the Dart SDK and remove the repository configuration:

sudo apt remove --purge dart
sudo rm /etc/apt/sources.list.d/dart.sources
sudo rm /usr/share/keyrings/dart.gpg
sudo apt update

Optionally, remove the Dart package cache and any project directories you created:

rm -rf ~/.pub-cache
rm -rf ~/my_dart_app

Verify Dart is completely removed:

which dart
apt-cache policy dart

Expected output confirming removal:

dart:
  Installed: (none)
  Candidate: (none)
  Version table:

Conclusion

You now have Dart installed on Debian with a verified test application demonstrating both JIT and AOT compilation. As a result, you have everything needed for command-line tools, server applications, and web development with dart2js.

To continue building with Dart, consider installing Visual Studio Code on Debian with the Dart extension for syntax highlighting and debugging support. For cross-platform mobile and desktop development, explore Flutter, which uses Dart as its programming language. If you’re new to programming on Debian, the Go installation guide covers another popular language for server-side development.

For comprehensive documentation and tutorials, visit the official Dart documentation.

Leave a Comment