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 Important Concepts

1. Anything placed in a variable is an object, and an object is an instance of a class.
Numbers, functions, and null are all objects in Dart, and all these objects inherit from the Object class except null (if sound null safety is enabled). 

2. Dart 2.12 supports null safety, which states that the code is non-nullable by default. This means that the variables can't contain null value unless we explicitly mention it using a question mark '?' at the end of its data type. With this feature, runtime null-dereference errors turn into edit-time analysis errors.

If you are sure that an expression can never evaluate to null, but Dart disagrees, you can add '!' to assert that it isn't null. 

3. Type annotations are optional in Dart, although it is a strongly typed language. Dart is capable of inferring types on its own by scanning the value assigned to the variable. 

4. Dart supports generic types as a list of integers like, List <int> or a list of objects, like List<Object>.

5. Dart supports the following functions :

  • Top-level functions like main( ) which is the entry point of the program.
  • Static Methods are the functions tied to a class.
  • Instance Methods are the functions tied to an object.
  • Nested or Local functions are the functions listed within the functions. 

6. Similarly, Dart supports the following variables : 

  • Top-level variables
  • Static variables are the variables tied to a class.
  • Instance variables are the variables tied to an object.

7. Unlike Java or C++, Dart doesn't have access specifiers like private, public, or protected to limit the accessibility of members of a class. 

To make a variable private, we can use underscore '_' before it. 

For example,  int _a;

In Dart, privacy is at the library level which means that all the other classes and functions within that library can access those members. So, in Dart we mainly have public or private accessibility.

8. Dart has expressions which have runtime values and as well as statements which don't have runtime values. 

For example, the conditional expression, 

condition ? expression1 : expression2 has a value of expression 1 if at runtime, condition evaluates to True or the value of expression 2 if the condition evaluates to False. In contrast, an if-else statement doesn't have any value. 

9. Dart tools report two kinds of problems : 

  • Warnings are the indications given by the compiler that the code might not work, but they don't prevent the program's execution. 
  • Errors are the problems in the code that prevent its execution. They are of two types : 
    • Compile-time error = This error prevents the code from executing at all. 
    • Runtime error = This error results in an exception raised during code execution. 

10. The Dart virtual machine ( VM ) is the core of the Dart language. It is mainly required when we are compiling our code using command line VM on the console. Another use is embedding it in another application, such as Dartium. 

11. Dartium is a customized build of Chromium with the Dart VM embedded in it. It executes the Dart code natively in the browser without converting it to JavaScript.