- Dart Programming - HTML DOM
- Dart Programming - Unit Testing
- Dart Programming - Concurrency
- Dart Programming - Async
- Dart Programming - Libraries
- Dart Programming - Typedef
- Dart Programming - Debugging
- Dart Programming - Exceptions
- Dart Programming - Packages
- Dart Programming - Generics
- Dart Programming - Collection
- Dart Programming - Object
- Dart Programming - Classes
- Dart Programming - Interfaces
- Dart Programming - Functions
- Dart Programming - Enumeration
- Dart Programming - Runes
- Dart Programming - Symbol
- Dart Programming - Map
- Dart Programming - Lists
- Dart Programming - Lists
- Dart Programming - Boolean
- Dart Programming - String
- Dart Programming - Numbers
- Dart Programming - Decision Making
- Dart Programming - Loops
- Dart Programming - Operators
- Dart Programming - Variables
- Dart Programming - Data Types
- Dart Programming - Syntax
- Dart Programming - Environment
- Dart Programming - Overview
- Dart Programming - Home
Dart Programming Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Dart Programming - Environment
This chapter discusses setting up the execution environment for Dart on the Windows platform.
Executing Script Onpne with DartPad
You may test your scripts onpne by using the onpne editor at
. The Dart Editor executes the script and displays both HTML as well as console output. The onpne editor is shipped with a set of preset code samples.A screenshot of the Dartpad editor is given below −
![Dartpad](/dart_programming/images/dartpad.jpg)
Dartpad also enables to code in a more restrictive fashion. This can be achieved by checking the Strong mode option on the bottom right of the editor. Strong mode helps with −
Stronger static and dynamic checking
Idiomatic JavaScript code generation for better interoperabipty.
You may try the following example using Dartpad
void main() { print( hello world ); }
The code will display the following output
hello world
Setting Up the Local Environment
In this section, let us see how to set up the local environment.
Using the Text Editor
Examples of a few editors include Windows Notepad, Notepad++, Emacs, vim or vi, etc. Editors may vary from one Operating System to another. The source files are typically named with the extension ".dart".
Instalpng the Dart SDK
The current stable version of Dart is 1.21.0. The dart sdk can be downloaded from −
A screenshot of the Dart SDK installation is given below −
![Dart Installation](/dart_programming/images/dart_installation.jpg)
On completion of the SDK installation, set the PATH environment variable to −
<dart-sdk-path>in
Verifying the Installation
To verify if Dart has been successfully installed, open the command prompt and enter the following command −
Dart
If installation is successful, it will show the dart runtime.
IDE Support
A plethora of IDEs support scripting in Dart. Examples include Ecppse, IntelpJ, and WebStorm from Jet brains.
Given below are the steps for configuring the Dart environment using WebStrom IDE.
Instalpng WebStorm
The installation file for WebStorm can be downloaded from
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 psted above
Create a new Dart project and configure Dart support
To create a new Dart project,
Cpck Create New Project from the Welcome Screen
In the next dialog box, cpck 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-cpck on the Project
New → Dart File
Enter the name of the Dart Script
A screenshot of the WebStorm Editor is given below −
![Dart File](/dart_programming/images/dart_file.jpg)
The dart2js Tool
The dart2js tool compiles Dart code to JavaScript. Compipng Dart code to JS enables running the Dart script on browsers that do not support the Dart VM.
The dart2js tool is shipped as a part of the Dart SDK and can be found in the /dartsdk/bin folder.
To compile Dart to JavaScript, type the following command in the terminal
dart2js - - out = <output_file>.js <dart_script>.dart
This command produces a file that contains the JavaScript equivalent of your Dart code. A complete tutorial on using this utipty can be found on the official Dart website.
Advertisements