Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published May 20, 2024
Contribute to Docs

In Dart, the .toDouble() method is used to convert numeric data types, such as int, to their corresponding double-precision floating-point representation.


  • numericValue: Represents the variable to be converted to double.


The following example demonstrates how to use the .toDouble() method to convert an integer to a double:

void main() {
int number = 3;
double value = number.toDouble();
print("Output = ${value}");

The above code produces the following output:

Output = 3.0

Note: The output 3.0 is a double. This can be confirmed by checking value.runtimeType.

All contributors

Looking to contribute?

Learn Dart on Codecademy