Dart Tutorial

Dart Tutorial Single-Page Application Architecture Dart Features Dart Installation Guide Dart Basic Program Dart Syntax Dart Keywords Dart Variables Dart Comments Dart Standard Input Output Dart Important Concepts

Data Types

Built-in Data Types Numbers Strings Booleans Lists Sets Maps Runes and Graphemes Symbols Enumerations Constants Queues

Other data types

Objects Future and stream Iterable Miscellaneous types

OPERATORS

Precedence and associativity Arithmetic operators Equality and Relational operators Type Test Operators Assignment Operators Logical Operators Bitwise and Shift Operators Miscellaneous operators

Control Flow Statements

Introduction If statement If-else statement If-else-if statement Loops Switch and case Dart Break And Continue Assert In Dart

FUNCTIONS

Dart function Types of Functions Anonymous function main( ) function Lexical scope and closure Recursion Common Collection Methods

Object Oriented Concepts

Dart Object-Oriented Concepts Dart Classes Dart Constructors Dart This Keyword Dart Super Keyword Static Members Method Overriding Dart Interfaces Inheritance Dart Abstract Classes Dart Builder Classes Dart Callable Classes

Dart Type System

Dart Type System Dart Soundness Dart Type Inference

MISCELLANEOUS

Dart Isolates Dart Typedef Dart Metadata Dart Packages Dart Generics Dart Generators Dart Concurrency Dart Unit Testing Dart Html Dom Dart URIs Dart Extends, With and Implements Keywords Dart Optional Parameters Rust Vs Dart C++ vs Dart Golang Vs Dart Dart Basics Exception Handling

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

Dart Installation Guide

Step – 2 : After clicking this hyperlink, you will be directed to the “Dart SDK Archive” page.

Dart Installation Guide

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.

Dart Installation Guide

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.

Dart Installation Guide

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.

Dart Installation Guide Dart Installation Guide

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.

Dart Installation Guide

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 Installation Guide

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

  1. VISUAL STUDIO CODE

Step – 1 : If you have already downloaded the VS Code. Go to extensions and search for Dart.

Dart Installation Guide

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’.

Dart Installation Guide

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.

Dart Installation Guide

It will direct you to the following page.

Dart Installation Guide

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.