DEV Community

Sujith V S
Sujith V S

Posted on

3 1

Dart Data Types - Cheat Sheet

Image description

//String
String className = "Sujith";
print(className);

//int
int b = 32;
print(b);

//double - for floating point numbers.
double avgmark = 35.6;
print(avgmark);

//num - Supports both double and int
num mygf = 4.3;
print(mygf);

//bool
bool activeClass = true;
print(activeClass);

var - supports all type of data
var teacherName = true;
print(teacherName);

dynamic - supports all type of data
dynamic mytchr = true;

print(mytchr);

Difference between var and dynamic data type in dart.
dynamic: can change TYPE of the variable, & can change
VALUE of the variable later in code. var: can't change
TYPE of the variable, but can change the VALUE of the
variable later in code.

//List
List studentName = ["Abhiram", "Aneesh",
"Vibin","Sujith"];
print(studentName);

List testList = [0, 1, 2];
print(testList);

List dynamicList = ["Sujith", 56, 78.3];
print(dynamicList);

//Map - key value pairs
Map mapVariable = {
"name" : "Sujith",
"age" : 27,
"Marks" : 89.3,
"Pass" : true,
"class" : "Flutter"
};
print(mapVariable);

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay