Setting up dart environment

Setting Dart Environment

Dart environment can be set locally as well as online compilers can be used for doing programs. But always online environment is not recommended becasue a good dart programmer programs in their local environment setup.

How can you execute a dart script online?

There are different online editors and compilers that is used in online for executing programs for different programming languages. For Dart we will be using online editor at https://dart.dev/ . This Dart Editor displays both the HTML and console outputs. An online editor contains a set of code samples.

This is how online dart editor looks like.

You may try the simple example using Dartpad

void main(){
  print("Hello World");
}

The output of the above s:-

Hello World

code Try Yourself

How can you setup a dart local environment ?

We use Text Editors for executing programs.Editors vary from one Operating System to another. The .dart extension is used for Dart programs.

The current version of Dart is 3.5.0-269.0.dev. To install Dart SDK, we use the appropriate pacakager manfer to develop the platform. The dart SDK can be downloaded to different Operating System.

Installing the Dart

Here are for Windows, Linux and MacOS.

  • First we need the editor for local environment download VScode or other editors.
  • Dart SDK (System Development Kit)

Dart SDK installation for Windows:-

  • Download SDK
  • Copy the dart-sdk folder to drive C.
  • Add the path of the SDK to environments variable.
  • Open the cms and check it it works.
  dart --version

Dart SDK installation for macOS:-

  • Install Homebrew from official tab.
  • Type dart brew tap dart-lang/dart in terminal
  • Type dart brew install dart in terminal
  • Verify that path includes Homebrew.

To Upgrade a new release of Dart dart brew upgrade dart in the terminal.

You can also switch dart verisons by installing to which you want to switch and dart brew unlink dart@<old> \ && brew unlink dart@<new> \&& brew link dart@<new> .

You can see the information of dart installed by dart brew info dart command.

Dart SDK installation for Linux:-

We can install SDK for linux using different package manager:-

SDK for Ununtu using apt-get command

  • dart sudo apt-get update for package update.
  • dart sudo apt-get install apt-transport https for installing secure HTTP package.
  • dart wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub \| sudo gpg --dearmor -o /usr/share/keyrings/dart.gpg for downloading and adding Google linux GPG public key.
  • dart echo 'deb [signed-by=/usr/share/keyrings/dart.gpg arch=amd64] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main' \| sudo tee /etc/apt/sources.list.d/dart_stable.list for dart package repository. dart $ sudo apt-get update && sudo apt-get install dart