×

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. 


Related Topics

Dart this Keyword

The ' this ' keyword, similar to that in Java and C#, refers to an object of the class using it. It points to the current object of the class,...

5 minutes read.

Dart Assignment Operator

Assignment operators are the operators that assign value to the variables. The value on the right-hand side is assigned to the variable on the left-hand side. We can also use...

4 minutes read.

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.

Dart Future and Stream

Before understanding Future and Stream in Dart, we need first to get familiar with two terms : Synchronous and Asynchronous Programming.  In synchronous programming, a single operation is handled at a...

9 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 - Control Flow Statements

The control flow statements are used to define the control on the flow of the program. Dart programs are executed in sequential order i.e., the order in which the programming...

1 minute read.

Dart Constants

Dart Constants are the objects or variables whose values can’t change or modify during the execution of the program. Their use case is when we want a particular value to...

2 minutes read.

Dart URIs

The Uri class supports encoding and decoding of strings with the help of functions to be used in URIs ( which may also be known as URLs ). These functions...

6 minutes read.

Dart Variables

Variables are used to store the value of a particular data type referred to in the whole program by a name or identifier. They refer to a memory location as...

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

Dart Built-in Data Types

A data type defines the type of value a variable can hold, such as integer, double, or string.  Dart supports two data types:  1. Built-in data types : These are the data...

1 minute read.

Interfaces in Dart

An interface in Dart refers to the syntax or blueprint that any class must adhere to. It basically defines the array of methods available on the object. It provides the...

3 minutes read.

Metadata in Dart

Metadata is often referred to as the data about the data. It is a  piece of data about a basic piece of data. In the case of a Dart program,...

2 minutes read.

Dart Concurrency

Dart concurrency allows us to run multiple or multiple components of a system at once. It issues several commands at once. Dart provides Isolates as a tool for performing compliance...

2 minutes read.

Dart Isolates

Dart successfully supports asynchronous programming which runs our program without any hindrance. This asynchronous programming is used to achieve concurrency. Dart supports concurrent programming with features such as ‘ async-await...

9 minutes read.

Dart Arithmetic Operators

Arithmetic Operators comprises of all the operators that are used to perform arithmetic operations such as addition, subtraction, multiplication, division, etc. They are binary operators that work upon two operands. Consider A...

2 minutes read.

Dart If statement

If statement is used to set the control on the lines of code. Using if statement, block of code is executed only if the expression in the statement returns true....

1 minute 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 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 Logical Operators

Logical operators are the operators that combine two or more conditions, and accordingly return a Boolean value : true or false. Assume the value of variable A is 25 and B...

2 minutes read.