Install Dart on Ubuntu 22.04

Install Dart on Ubuntu 22.04

Dart is a programming language that often used to develop web and mobile applications. Dart is a cross-platform and open-source language developed by Google.

This tutorial explains how to install Dart on Ubuntu 22.04.

Install Dart

Run the following command to download GPG key:

sudo wget -qO /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc https://dl-ssl.google.com/linux/linux_signing_key.pub

Add the Dart repository:

sudo wget -qO /etc/apt/sources.list.d/dart_stable.list https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list

Update the package lists and install Dart:

sudo apt update
sudo apt install -y dart

When installation is completed, we can check Dart version:

dart --version

Testing Dart

Create a main.dart file:

nano main.dart

Add the following lines of code:

void main() {
  print('Hello world');
}

Run a Dart file:

dart main.dart

Uninstall Dart

If you wish to completely remove Dart, run the following command:

sudo apt purge --autoremove -y dart

Remove GPG key and repository:

sudo rm -rf /etc/apt/trusted.gpg.d/dart_linux_signing_key.asc
sudo rm -rf /etc/apt/sources.list.d/dart_stable.list

You can also remove user-level settings for Dart:

rm -rf ~/.dart

Leave a Comment

Cancel reply

Your email address will not be published.