×

Dart Tutorial

Dart is an open-source, structured programming language developed by Google. It is a high-level programming language that emerged in 2011, but its stable version emerged in 2017. It is largely used to build web and mobile applications.

The language syntax of Dart language is very similar to that of Java, C#, and JavaScript. The primary goal for creating Dart language was that the language seemed familiar to the developers. It is a class-based, optionally typed and single-threaded language with closure and lexical scope. It supports some additional features such as interfaces, mixins, abstract classes, generics, and type inference.

Dart is more than just a language; it comprises of an entire ecosystem that helps in improving the workflow while building complex web applications.

Dart Tutorial

Dart Ecosystem

It is widely used to develop mobile applications, modern web apps, desktop applications, and the Internet of Things (IoT) using the flutter framework. The best example of Dart applications is Gmail.

There are various ways of running an application created in Dart, either by using a browser that supports Dart like, Dartium browser or compiling the Dart code to JavaScript using the Dart2js tool. It can also be run on the command line, hosted in a Dart Virtual Machine. This feature allows the application's client and server parts to be written in the same language. There are two compilation techniques: 

  • Ahead of Time (AOT): Code compilation takes place at the build time. In this technique, the Dart code is converted into JavaScript code using the dar2js compiler, making it run on all modern web-browser. 
  • Just-In-Time (JIT): In this technique, only necessary byte code is converted into machine code. 

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.

History of Dart

Dart emerged at the GOTO conference in Aarhus, Denmark, for the very first time in October 2012 as a project by Lars Bak and Kasper Lund. Later, on November 14, 2013, Dart 1.0 was released.

In July 2014, Ecma International approved the first edition of Dart language at its 107th General Assembly and the second edition in December 2014.

Dart 1.9, released in 2015, focussed on compiling Dart to JavaScript. And, then in August 2018, Dart 2.0 was released with some change in language and a sound type system.

Dart2native, a new extension, was introduced in a new version of Dart, Dart 2.6, which extends native compilation to various operating systems and desktop platforms. With this extension, it became possible to compose a Dart program into self-contained executables. This newer extension was integrated with Flutter to use the compiler for backend services.

Characteristics

  1. Dart is a dynamic object-oriented programming language supporting all the features of object-oriented paradigms.
  2. It is a platform independent language that supports all the operating systems such as Windows, Mac, Linux, etc.
  3. It is a BSD licensed and Ecma standardized language.
  4. Every number, Boolean function, etc., are treated as an object in Dart. All such objects inherit from the Object class.
  5. Dart tools also report some warnings and errors, if any. Warnings indicate problems in the program but don’t interrupt the code’s execution, whereas errors don’t let the program be executed.

HIGH-LEVEL PROGRAMMING FEATURES COMPARISON

Feature         Dart         Java    JavaScript
Type SystemDart supports dynamic type system, but is optional.Java supports strong and static type system.JavaScript supports weak but dynamic type system.
First-class functionsIt supports first class functions.It doesn’t support first class functions but can be simulated with anonymous functions.It supports first class functions.
ClosuresClosure feature is supported.Closure is supported using anonymous classes.Closure feature is supported.
ClassesThere are classes that follow single inheritance.There are classes that follow single inheritance.There are classes with prototypical inheritance.
InterfacesThere are  multiple interfaces.There are multiple interfaces.There is no interface.
ConcurrencyThere is concurrency with isolates.There is concurrency with threads.There is concurrency with HTML5 web  workers.

Prerequisite

There is no pre-requisite to learning the Dart programming language, and it is an easily understandable language even for beginners. The syntax of Dart is very similar to C#, Java, JavaScript, etc. Therefore, people already familiar with these programming languages can easily understand and learn the Dart language efficiently.

Audience

This tutorial has been developed keeping in mind all the readers at beginner, intermediate or professional levels. This is best suited for those who want to build a career in web development, Dart or Flutter. There is list of topics available under this tutorial that will help you learn the Dart programming language easily.

DART Tutorial Index

Data Types

Other data types

OPERATORS

Control Flow Statements

FUNCTIONS

Object Oriented Concepts

Dart Type System

MISCELLANEOUS


Related Topics

Dart Basic Program

Dart provides various convenient platforms to code and compile the program in Dart language. Some of them are: 1. Using IDE = Visual Studio code is a text editor with IDE....

3 minutes read.

Abstract Classes in Dart

Abstract classes in Dart are those classes that only contain abstract methods  (methods that do not contain any implementation). These classes are specifically designed for the purpose of inheritance. We...

4 minutes read.

Lexical Scope and Closure

Lexical Scope : Lexical scope is a very important term in any programming language. It defines the scope of the variable based on the block it is contained inside. According to...

2 minutes read.

Dart Keywords

Keywords are the reserved words of a programming language, and they have a special meaning that comes defined by the language. These cannot be used as an identifier, and all...

1 minute read.

Dart Recursion

Recursion is one of the most important and interesting concepts in any programming language. It can be defined as a process in which a function calls itself directly or indirectly....

5 minutes read.

Dart If-else-if statement

If - else - if statement enables to check the set of test expressions that evaluate to Boolean True or False, and based on this true or false the particular...

2 minutes read.

Dart If-else statement

In the previous section, we studied about if statements in detail. If – block is executed when the condition evaluates to true, else if the condition evaluates to false, then...

1 minute read.

Dart Generators

Synchronous Generator Dart Generator is a unique function that allows us to generate price sequences. Generators return values when needed; means that the value is generated if we try to duplicate...

5 minutes read.

Dart Numbers

Dart provides an in-built data type ‘Numbers’ that provides two types of values: intdouble 1. int data type int data type supports integer values, and their size or values range is platform-dependent. Integers...

4 minutes read.

Dart Type inference

The task of interpreting the data types of fields, methods, local variables and most generic type arguments is handled by the static analyser. However, when not enough information is provided...

5 minutes read.

Dart Sets

Sets data type in Dart A set is an unordered collection of items that are unique. Dart infers that sets tale strings as values. Example, var languages = { ‘Dart’ , ‘Flutter’, ‘Python’,...

3 minutes read.

Dart Inheritance

Inheritance is a promising concept of any programming language. It is a property by which a class inherits the property of another class. Moreover, the class deriving the properties of...

5 minutes read.

Dart - extends, with and implements Keywords

The application development in Dart programming language using the Flutter framework, regularly experience different usage of the implements, extends and with keywords. Dart has full support for inheritance that is...

5 minutes read.

Dart Static Members

Static Members in Dart Static members are the members of the class declared using the 'static' keyword. the static members have the following characteristics :  All the objects of the class having...

3 minutes read.

Type System in Dart

Dart language is a type safety enabled language that uses static and dynamic type checking to match the value of the variable with its data type at the compile-time. This...

4 minutes read.

Dart super keyword

The ' super ' keyword is used to refer to the immediate parent class object of the currently in-use child class. Using this keyword, we can invoke the superclass (...

6 minutes read.

Dart Objects

Apart from the built-in data types, Dart offers some other data types that have a special role to play. One of them is Objects.  Objects Objects are the foundation of the...

3 minutes read.

Dart Miscellaneous types

Some Other Data types in Dart Apart from the data types studied so far, we have three other data types also which are as follows: NeverDynamicVoid Let us understand each one in detail, Never...

3 minutes read.

Dart Break and Continue

Loop statements are used to change the normal sequence of flow of the program. Dart supports two types of loop control statements: Break StatementContinue Statement Break Statement : The ‘ break ’ statement is...

4 minutes read.

Dart Iterable

Iterable is a collection of elements that are accessed sequentially. These elements are accessible using the iterator getter and stepping through the values using this getter. Let us understand the setting...

6 minutes read.