UbuntuUbuntu Based

How To Install Dart Programming Language on Ubuntu 24.04

Install Dart Programming Language on Ubuntu 24.04

In this tutorial, we will show you how to install Dart Programming Language on Ubuntu 24.04 LTS. Dart is a versatile, open-source programming language developed by Google that has gained significant popularity in recent years. Known for its simplicity, efficiency, and scalability, Dart is widely used for building web, server, and mobile applications. With its growing community and extensive libraries, Dart has become a go-to choice for developers seeking a modern and powerful language.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Dart programming language on Ubuntu 24.04 (Noble Numbat). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.

Prerequisites

  • A server running one of the following operating systems: Ubuntu and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • Basic familiarity with the command line interface.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
  • An Ubuntu 24.04 system with root access or a user with sudo privileges.

Install Dart Programming Language on Ubuntu 24.04

Step 1. Updating the Package Repository.

To ensure a smooth installation process, it’s crucial to update your Ubuntu system to the latest version. Open the Terminal and execute the following commands:

sudo apt update
sudo apt upgrade

These commands will fetch the latest package lists and upgrade any outdated packages to their latest versions.

Step 2. Installing Dart Programming Language on Ubuntu.

  • Installing Dart via APT Repository

One of the easiest and most reliable ways to install Dart on Ubuntu is through the APT (Advanced Package Tool) repository. Follow these steps to add the Dart repository and install Dart:

sudo apt-add-repository ppa:dart-lang/stable

Install Dart using APT:

sudo apt update
sudo apt install dart

Verify the installation by checking the Dart version:

dart --version
  • Installing Dart via Snap

Snap is a popular package management system that simplifies the installation and management of software packages on Linux. Here’s how you can install Dart using Snap:

sudo apt install snapd

Install Dart using the following Snap command:

sudo snap install dart --classic

Verify the installation by checking the Dart version:

dart --version

If the installation was successful, you should see the installed Dart version displayed in the Terminal.

  • Installing Dart from Source

In some cases, you may prefer to install Dart from its source code. This method allows you to have more control over the installation process and enables you to install specific versions of Dart. Follow these steps to install Dart from source:

Install the necessary build tools and dependencies:

sudo apt install git build-essential

Clone the Dart SDK repository from GitHub:

git clone https://github.com/dart-lang/sdk.git

Navigate to the cloned repository directory:

cd sdk

Check out the desired version or branch of Dart (optional):

git checkout <version-or-branch>

Build and install Dart:

./tools/build.py --mode release --arch x64
sudo cp -r out/ReleaseX64/dart-sdk /usr/lib/dart

Set up the Dart environment variables:

echo 'export PATH="$PATH:/usr/lib/dart/bin"' >> ~/.bashrc
source ~/.bashrc

Verify the installation by checking the Dart version:

dart --version

If the installation was successful, you should see the installed Dart version displayed in the Terminal.

Step 3. Configuring Dart Environment.

After installing Dart, it’s important to ensure that your system is properly configured to recognize and use the Dart SDK. Follow these steps to set up the Dart environment:

Open the .bashrc file in a text editor:

nano ~/.bashrc

Add the following line at the end of the file:

export PATH="$PATH:/usr/lib/dart/bin"

Save and close then, reload the .bashrc file to apply the changes:

source ~/.bashrc

Verify the Dart environment setup by running a Dart command:

dart --version

If the environment is set up correctly, you should see the installed Dart version displayed in the Terminal.

Step 4. Set Up a Dart Project.

Create a new directory for your Dart project and navigate to it in the Terminal. Initialize a new Dart project using the following command:

dart create myproject

Open your favorite text editor and create a new file named main.dart in your project directory. Write a simple Dart program, such as a “Hello, World!” example:

void main() {
print('Hello, idroot.us World!');
}

Save the file and run the program using the Dart VM:

dart run main.dart

You should see the output “Hello, idroot.us World!” in the Terminal, confirming that your Dart setup is working correctly.

Congratulations! You have successfully installed Dart. Thanks for using this tutorial for installing the Dart programming language on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Dart website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button