What is Dart

Dart is a client-optimized programming language for fast multi-platform apps.

It is a modern, UI-focused language that’s compiled to native ARM or x86 code or cross-compiled(transpiled) to Javascript.

The Dart virtual machine allows lightning fast development-time rebuilds, its JavaScript complier allows you to build for the web, and its ahead-of-time compiler creates fast native applications across mobile and desktop platforms and even for servers and embedded devices.

It can also be used as an interpreted language because of Dart VM.

Dart’s compiler technology lets you run code in different ways:

Native Platform

Web Platform

Regardless of which platform you use or how you compile your code, executing the code requires a Dart runtime which is responsible for the following critical tasks:

On native platforms, the Dart runtime is automatically included inside self-contained executables, and is part of the Dart VM provided by the dart run command.

Dart is designed for a technical envelope that is particularly suited to client development, prioritizing both development (sub-second stateful hot reload) and high-quality production experiences across a wide variety of compilation targets (web, mobile, and desktop).

Dart CLI

Library Support

Dart has a rich set of **core libraries(**built in), providing essentials for many everyday programming tasks.

The Dart team publishes many useful supplementary packages, that one can get from pub (dart package manager).

Third-party publishers and the broader community publish thousands of packages, that one can get from pub. (By Community 💖)

Important Concepts

Everything you can place in a variable is an object, and every object is an instance of a Object class.

In Dart statements and expressions ends with a semicolon (;). Semicolons give the compiler the context it needs to properly understand the code.

Although Dart is strongly typed, type annotations are optional because Dart can infer types.

If you enable null safety, variables can’t contain null unless you say they can. To make a variable nullable put a question mark (?) at the end of its type.

When you want to explicitly say that any type is allowed, use the type Object?, Object, or dynamic, if you must defer type checking until runtime (Runtime Type Checking or Type Inference).

Dart supports top-level functions (such as main()), as well as functions tied to a class or object (static and instance methods, respectively). You can also create functions within functions (nested or local functions).

Dart supports top-level variables, as well as variables tied to a class or object (static and instance variables). Instance variables are sometimes known as fields or properties.

Unlike Java, Dart doesn’t have the keywords public, protected, and private (access specifiers). If an identifier starts with an underscore (_), it’s private to its library.

Identifiers can start with a letter or underscore (_), followed by any combination of those characters plus digits.

Dart has both expressions (which have runtime values) and statements.