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);

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay