Dart Programming - Environment

To  run or compile Dart apps we need to have the Dart SDK installed. The official documentation is very good and can be used for this step https://dart.dev/get-dart

 

DartPad

We have an Online editor to run dart programs. we can find it here https://try.dartlang.org/

 

Setting Up the Local Environment

The SDK can be downloaded from the Dart installation website.

Follow the instructions for your operating system.

After that the Dart SDK should be automatically added to your path.

To test the availability of dart, type dart --version in a terminal.

In Linux 

On Linux Dart is typically installed in /usr/lib/dart/bin.

To add it to your path, simply add 

export $PATH:/usr/lib/dart/bin at the end of the .bashrc file in your home directory

MacOs

Add /Applications/dart/dart-sdk/bin at the end of /etc/paths

 

Windows

in windows after installtion set the PATH environment variable to

<dart-sdk-path>\bin 

 

Verifying the Installation

To verify if Dart has been successfully installed, open the command prompt and enter the following command 

Dart 

 

Supported IDEs

There are multiple IDEs supporting Dart programming

Few are Eclipse, IntelliJ, and WebStorm from Jet brains

 

Installing WebStorm

The installation file for WebStorm can be downloaded from https://www.jetbrains.com/webstorm/download/#section=windows-version.

The WebStorm installation file is available for Mac OS, Windows and Linux.

After downloading the installation files, follow the steps given below −

  • Install the Dart SDK: Refer to the steps listed above

  • Create a new Dart project and configure Dart support

  • To create a new Dart project,

    • Click Create New Project from the Welcome Screen

    • In the next dialog box, click Dart

  • If there is no value specified for the Dart SDK path, then provide the SDK path. For example, the SDK path may be <dart installation directory>/dart/dartsdk.

Add a Dart File to the Project

To add a Dart file to the Project −

  • Right-click on the Project
  • New → Dart File
  • Enter the name of the Dart Script