Appendix A. Core language reference

 

The core Dart language consists of variables and operators, a number of built-in types, flow-control statements, and function blocks. Dart is a dynamically typed language, similar to JavaScript, and type information in variable and parameter declarations is optional. The Dart virtual machine executes Dart code identically whether type information is provided or not. Any type information provided is used by tools to confirm the developer’s intention and provides documentation to future developers who may need to read and maintain the code.

A.1. Variable declaration

A variable is declared by prefixing the variable name with one of the following:

  • The var keyword (indicating a dynamic type, or no type information is supplied)
  • A type name (indicating that type information is provided)
  • The final keyword (indicating a dynamic read-only variable)
  • The final keyword followed by a type name (indicating a typed read-only variable)

Dynamic variables can contain values of any type, but typed variables are checked by the Dart tools, which ensure that the variable contains a value of the type indicated.

You assign a variable a value using the assignment operator =:

A.1.1. Declaring variables with the var keyword or type name

A.2. Functions

A.3. Flow control and iterating