×

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 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 Booleans

Booleans Dart has a data type named ‘bool’ to represent Boolean values : true and false, which are compile-time constants. ‘True’ or ‘False’ cannot be assigned with values 1 or 0. Example, bool...

1 minute read.

Dart Symbols

Symbols data type in Dart A symbol is an object that is the representation of an operator or identifier in Dart. These are compile-time constants.  They are used in APIs that refer...

1 minute 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 Equality and Relational Operators

Dart provides the functionality of checking the relationship between the values or values within the variables. These operators return the resultant value as Boolean, i.e., either ‘true’ or ‘false’. Some important points...

3 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 lists data type

The most important data type in any programming language is an ordered list of elements, an array. Dart lists resemble JavaScript array lists. Example,               var...

7 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 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 Features

Dart is a fully-featured, object-oriented modern language with its roots in the programming language ‘Smalltalk’. It has some of its eminent features similar to the languages such as Java, C#...

4 minutes read.

C++ vs Dart

Difference between C++ and Dart C++ is an object-oriented programming language developed in 1980 by Bjarne Stroustrup. It has wide real-world applications with various in-built functions and a very vast library...

1 minute read.

Dart Optional Parameters

Dart functions can have optional parameters with default values. When we create a function, we can specify parameters that calling code can provide; but if the calling code chooses not...

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

Assert in DART

In any programming language, resolving error is the most unwanted and tedious task. At times it becomes very difficult to find the error in the large code. Dart offers an...

3 minutes 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 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 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 - 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 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.

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.