Data Types In Dart Programming Language.

08.20.20-What-is-Dart-and-how-is-it-used-1320x742.jpg Data types are the most essential features of a programming language. In Dart, the data type of the variable is defined by its value.

Dart supports the following built-in Data types:

  • Number
  • Strings
  • Boolean
  • Lists
  • Maps

Numbers

Numbers in dart represent numeric values that can further be classified into two types:

  • Integer – numerical values without a decimal point or whole numbers. E.g., the value 5 is an integer
  • Double- fractional numeric values or values with a decimal point.

    Strings

    A string is a sequence of characters. If we store data like – name, address etc. it is signified by using either single quotes or double quotes.
var name ='mike';

Boolean

The Boolean type like in all other programming languages represent two values – true and false.

bool isHim = true;

Lists

A list is a collection of ordered objects or values. Elements in a list are separated by a comma enclosed in a square bracket[]. Look at the example below.

var myList= [1, 2, 4, 56, 4.6];

Maps

Dart map type is used to store values in key value pairs like dictionary in python if familiar. Each key is associated with its value. The key and value can be any type. In Map, the key must be unique, but a value can occur multiple times. Maps are defined using curly braces {}, and comma separates each pair.

var employee={'name':'john', 'department':'IT', 'age': 12}