Introduction to Dart Programming Language

Dart is the open-source programming language originally developed by Google. It is meant for both server side as well as the user side. The Dart SDK comes with its compiler – the Dart VM and a utility dart2js which is meant for generating Javascript equivalent of a Dart Script so that it can be run on those sites also which don’t support Dart. 

Dart is Object-oriented language and is quite similar to that of Java Programming. Dart is extensively use to create single-page websites and web-applications. Best example of dart application is Gmail.

You can install Dart SDK from their official website or download the installer from this site.

Installation

For Windows OS: 



To install dart in window system we will be using Chocolatey.

To install Dart:

C:\> choco install dart-sdk

To Update Dart:

C:\> choco upgrade dart-sdk

For Linux OS:

 If you’re using Debian/Ubuntu on AMD64 (64-bit Intel), you can choose one of the following options, both of which can update the SDK automatically when new versions are released.

Install using apt-get: 

Perform the following one-time setup:

$ sudo apt-get update
$ sudo apt-get install apt-transport-https
$ sudo sh -c 'wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -'
$ sudo sh -c 'wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list'

 Then install the Dart SDK:

$ sudo apt-get update
$ sudo apt-get install dart

Install a Debian package:

Download Dart SDK as Debian package in the .deb package format.



Modify PATH for access to all Dart binaries

After installing the SDK, add its bin directory to your PATH. For example, use the following command to change PATH in your active terminal session:

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

To change the PATH for future terminal sessions, use a command like this:

$ echo 'export PATH="$PATH:/usr/lib/dart/bin"' >> ~/.profile
$ brew tap dart-lang/dart
$ brew install dart

To upgrade when a new release of Dart is available:

$ brew upgrade dart

First Code in Dart: 
In dart main() function is predefined method and acts as the entry point to the application. A dart script needs the main() method for execution of the code. The program code goes like this: 
 

Dart

filter_none

edit
close

play_arrow

link
brightness_4
code

main() {
    print("Welcome to GeeksForGeeks");
}

chevron_right


Output:

Welcome to GeeksForGeeks

The print() command is predefined function that prints the specific string or value to the standard input.

Execution of program:

  1. Online Compiler: The online compiler which support Dart is Dart Pad.
  2. IDE: The IDEs which support Dart are WebStorm, Intellij, Eclipse, etc. Among them WebStorm from Jetbrains is available for Mac OS, Windows and Linux.
  3. The dart program can also be compile through terminal by executing the code dart file_name.dart.

 

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.