0% found this document useful (0 votes)
2 views2 pages

Dart Data Types Notes Clean

The document outlines various data types in Dart, including primitive types like int, double, and bool, as well as collections such as List, Map, and Set. Each data type is defined with examples demonstrating its usage. Additionally, it covers type inference with 'var' and the flexible 'dynamic' type.

Uploaded by

merala5972
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Dart Data Types Notes Clean

The document outlines various data types in Dart, including primitive types like int, double, and bool, as well as collections such as List, Map, and Set. Each data type is defined with examples demonstrating its usage. Additionally, it covers type inference with 'var' and the flexible 'dynamic' type.

Uploaded by

merala5972
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Dart Data Types - Notes

Definition:

A data type is the characteristic of a variable that determines what kind of data it can hold. Data types include

primitive types like int, double, bool, etc., as well as collections like List, Map, Set.

1. int - Integer

Used to store whole numbers (positive or negative) without decimal points.

Ex:

int age = 25;

2. double - Decimal Number

Stores floating-point (decimal) numbers.

Ex:

double pi = 3.1416;

3. num - Super Type for int and double

Can hold both integers and decimal numbers.

Ex:

num a = 10;

a = 10.5;

4. String - Text or Characters

Stores a sequence of characters (text).

Ex:

String name = "TheXcode";

5. bool - Boolean

Stores true or false values.

Ex:
Dart Data Types - Notes

bool isLoggedIn = true;

6. var - Type Inference

Automatically detects and assigns the data type based on value.

Ex:

var city = "Indore";

7. dynamic - Changeable Type

Can hold any type of value and can change at runtime.

Ex:

dynamic value = 10;

value = "Hello";

8. List - Collection (like Array)

Stores an ordered group of values.

Ex:

List<String> names = ["Ram", "Shyam", "Golu"];

9. Map - Key-Value Pairs

Stores values as a pair of key and value.

Ex:

Map<String, int> marks = {"Math": 90, "English": 80};

10. Set - Unique Collection

Stores unique items (no duplicates).

Ex:

Set<int> ids = {1, 2, 3};

You might also like