...

/

Numbers

Numbers

Let’s learn about Dart's number types.

The num Type

If we want a variable that has a number value, we will declare it using the num data type. The basic syntax is as follows:

Press + to interact
// Method 1
num variableName = Number Literal
// Method 2
num variableName = Number Variable

Let’s look at an example.

Press + to interact
main() {
num firstNumber = 5;
num secondNumber = 5.1;
num thirdNumber = firstNumber;
// Driver Code
print(firstNumber);
print(secondNumber);
print(thirdNumber);
}

Dart numbers are further divided into two subtypes:

...

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy