Dart Installation Guide
There are various ways of compiling and running an application created in Dart, either by compiling the Dart code to JavaScript using the Dart2js tool or by running on the command line, hosted in a Dart virtual machine using SDK. This feature allows the application's client and server parts to be written in the same language. Online compiler Dart Pad can also be used to run Dart code. Some IDEs which support Dart language are WebStorm, Intellij, Eclipse, Visual Studio Code, Android Studio, etc.
SDK (SOFTWARE DEVELOPMENT KIT) INSTALLATION
Follow the below instructions to install Dart SDK on Windows.
Step – 1 : Go to the browser and search ‘get Dart SDK’. Click on the first hyperlink, “Get the Dart SDK”, and scroll down to the bottom of the page and select the hyperlink “downloading the SDK as a zip file”.
Or directly visit the following link : https://Dart.dev/get-Dart/archive
Step – 2 : After clicking this hyperlink, you will be directed to the “Dart SDK Archive” page.
To download any other version of Dart for any other Operating system, directly choose from Version and OS dropdown menu (circled with greens).
On clicking, the download will begin, and a zip file will be downloaded.
Step – 3 : Open the zip file and extract the contents of the file to a suitable location as follows.
Step – 4 : Select and open the bin folder and copy the path by right-clicking on the bar that specifies the location.
Step – 5 : Go to advanced settings under System Properties and click on the ‘Environment Variables’ button to add the SDK path.
After clicking, the following dialogue box will appear. Under system variables, click on the path and create space for a new path and paste the path you copied.
Click ‘ok’ after adding the new path. The path will be successfully added!
Step – 6 : Run Dart using the command prompt. Search for the command prompt and write Dart, and press enter. Various commands are listed to operate with Dart code.
You will first have to write the code in Notepad and run it using the command prompt.
Dart2js Tool
The Dart2js tool comes in-built with the Dart SDK. This tool converts the Dart language code into JavaScript code, making it compatible with modern web browsers.
In order to compile the Dart code into JavaScript, write the following command in command prompt,
Dart2js - - out = <output_file>.js <Dart_script>.Dart
This will generate an equivalent JavaScript code.
DartPad
Step – 1 : Search DartPad on the browser and click on the first hyperlink. Or directly click on https://Dartpad.dev/
The following page will open.
Dart IDE
The IntelliJ, WebStorm and Eclipse are some of the IDEs from Jet brains that support the Dart language.
WebStorm can be downloaded from the given link,
https://www.jetbrains.com/webstorm/download/#section=windows-version
- VISUAL STUDIO CODE
Step – 1 : If you have already downloaded the VS Code. Go to extensions and search for Dart.
Step – 2 : Install “Dart language support and debugger for visual studio code”.
Step – 3 : Create a new file, write your code and save it with extension ‘.Dart’.
Step – 4 : Compile and run the code by either pressing F5 or the play button.
Step – 5 : If you haven’t downloaded the VS Code. Search on Google ‘download VS Code’ and click on the first hyperlink.
It will direct you to the following page.
Step – 6 : Choose the correct option with respect to the operating system you are working on. Downloading will begin, and an exe setup file will be downloaded.
Step – 7 : Open and run the file. Proceed with choosing the right location, and Visual Studio will be installed.
Step – 8 : Follow the steps from 1 to 4 to run the Dart language code.