How to Install Dart on Linux?
This article will cover the topic of how you can install Dart SDK on a Linux system. Before we dive into installation let’s first take a small overview of Dart, its applications, and system requirements to install Dart in a Linux system. At the time of writing this article, the latest stable release version was 2.14.3.
What is Dart?
A quick search on google will give you that,
Dart is a programming language designed for client development, such as for the web and mobile apps. It is developed by Google and can also be used to build server and desktop applications. Dart is an object-oriented, class-based, garbage-collected language with C-style syntax.
It is highly optimized for fast client-side UI and app development. Dart is commonly used in Flutter development. So, if you want to learn Flutter you have to learn “at least” the basics of Dart to start with. But the C-style and simple syntax of Dart makes it easier to cope up with.
Before you install:
As of Flutter 1.21, the Flutter SDK includes the full Dart SDK. So if you have Flutter installed, you might not need to explicitly download the Dart SDK. Consider downloading the Dart SDK if any of the following are true:
- You don’t use Flutter.
- You use a pre-1.21 version of Flutter.
- You want to reduce disk space requirements or download time, and your use case doesn’t require Flutter. For example, you might have continuous integration (CI) setup that requires Dart but not Flutter.
System requirements for Linux:
- Supported versions: Debian stable and Ubuntu LTS under standard support.
- Supported architectures: x64, ia32, arm, arm64.
Note: The arm support requires glibc 2.23 or newer due to dynamic linker bug.
If you’re using Debian/Ubuntu on AMD64 (64-bit Intel), you can choose one of the following options, both of which can update the SDK automatically when new versions are released.
- Install using apt-get
- Install a Debian package
Installing Dart using apt-get on Linux:
Note: Here we are doing this part on the Parrot OS, which is a Debian-based Linux distro.
Before installing the Dart package we first need to add the repository to the apt manager which has the Dart package. To do so, we need to do a one-time setup.
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'
This will add the google repository in your package manager. The screenshots of running the following commands are attached below.
sudo apt update / 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 -'
Ignore the deprecated warning for now.
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'
This command will be executed without any output.
After this one-time setup of adding the repository to the apt package manager, we install the Dart package. We first do an update before installing Dart.
sudo apt-get update
Note the new repositories that we added in the setup step of the installation.
sudo apt-get install dart
This will successfully install dart in your system.
Install a Debian package:
Note: Here we are doing this part on Ubuntu, which is a Debian-based Linux distro.
To install dart using a Debian package, you can first download Dart SDK as a Debian package in the “.deb” format. After downloading you can open the deb package in Ubuntu Software and install it,
Or, you can use the command:
$ dpkg -i dart_2.14.4-1_amd64.deb
After installing, we need to add its bin directory to your PATH. For doing so for the active terminal session, use:
$ export PATH="$PATH:/usr/lib/dart/bin"
To change the PATH for future terminal sessions, use a command like this:
$ echo 'export PATH="$PATH:/usr/lib/dart/bin"' >> ~/.profile
Both these commands will run without any output.
Verifying the Installation:
You can use commands,
$ dart --version
to verify if dart is successfully installed in your system.
Note: There is another way to install dart from the source, for that you can check this link. But it’s a long process as you’ll need to install many dependencies before compiling the source code. So, I’ll suggest one of the above two ways instead.
Please Login to comment...