Understanding Data Types in Dart

Data Types in Dart

One of the basic characteristics of a programming language is the data types it supports. These are the type of values that can be given and manipulated in a programming language. In Dart there are basically 6 Types of Data type available.

Dart supports following built in data types:

1.Numbers

2. Booleans

3. Lists

4. Strings

5. Maps

6. Runes

1. Numbers

Dart number has two subtypes:

  • Integar

Dart Integar is a type of non-fractional number value without point. It can have any value from natural numbers and their negative counterparts. Integars can be declared with int keyword.

  • Double

Dart Double is used to represent a 64-bit floating numbers or fractional decimal values. They can be declared with double keyword.

2. Booleans

Boolean is used to keep true and false values. Boolean data type uses the “bool” keyword on declaration time. They are mostly used in decision making statements.

3. Lists

Lists data type is used to represent a collection of objects. It is similar to the concept of an array in other programming languages.

4. Strings

Strings are sequence of characters or bunch of characters. It can be used to keep any number of characters like names, personal details and different kind of information. You can use single and double quotes to define a string.

5. Maps

Dart Maps is used to represent a set of values in key value pairs format. Each key is associated with one value in Maps. Both keys and values can be of any type for mapping.

6. Runes

The Runes type also represents strings, but unlike String, Runes are a sequence of UTF-16 characters. Since by default all quoted strings (both single and double) are of the String type, a special syntax is required to define the Runes variable. First comes the “new” operator, then the type name – Runes, followed by the argument passed to the constructor in parentheses. We can pass to the constructor either a set of UTF-16 encoded code units (new Runes(‘\u041F\u0440\u0438\u0432\u0435\u0442’)), or a regular set of characters (new Runes(‘Hello’)).

Recommended Articles

Share
Tweet
Pin
Share
Share