Int data type

In Dart, int is a built-in data type under Number category.

If Dart application is made for native platforms like Windows, Linux, Mac, etc., variables of type int can hold values in the range [-263, 263-1].

If Dart application is made for web, then variables of type int in JavaScript can hold values in the range [-253, 253-1].

Define Int Variable

Use int keyword to define a variable of type integer, as shown in the following.

int x = 25;

In Dart, we can assign an integer value to a variable declared using var keyword, then the type of the variable would become int.

var x = 25;         // type of x is int

Operations on Integer Values

We can perform arithmetic operations like addition, subtraction, multiplication, division, etc., on values of integer type.


void main() {
    int x = 5;
    int y = 4;
    print('x + y = ${x + y}');
    print('x - y = ${x - y}');


x + y = 9
x - y = 1


In this Dart Tutorial, we learned about int datatype and how this type is used to store integer values, with examples.