Flutter: Data types

Dart supports several data types. In this article, we will learn about some of them:

NameExamples
String"Hello world"
int1, 5, 10, 100
double1.5, 0.25, 10.5
num1, 1.5, 10
booltrue, false

String

The String data type holds a sequence of characters. You can create a string using single quotes ' or double quotes ".

var myString1 = 'This is a string';
var myString2 = "This is another string";

int

The int data type holds integer values no larger than 64 bits, depending on the platform. On native platforms, values can be from -263 to 263 - 1. On the web, integer values are represented as JavaScript numbers (64-bit floating-point values with no fractional part) and can be from -253 to 253 - 1.

var myNumber = 5000;

double

The double data type holds floating-point numbers.

var myDouble = 1.25;

num

The num data type can hold integers or floating-point numbers. For example:

num myNum1 = 100;
num myNum2 = 1.25;

bool

The bool data type can hold only two values: true or false:

var myBoolean = true;

DartPad example

Conclusion

We learned about some of the data types supported by Dart. Of course, there are many more data types like Maps, Lists, Sets, etc. But we will learn about them in the following articles of this course.

Share this article