integer_literal_imprecise_as_double
The integer literal is being used as a double, but can't be represented as a 64-bit double without overflow or loss of precision: '{0}'.
Description
#The analyzer produces this diagnostic when an integer literal is being implicitly converted to a double, but can't be represented as a 64-bit double without overflow or loss of precision. Integer literals are implicitly converted to a double if the context requires the type double
.
Example
#The following code produces this diagnostic because the integer value 9223372036854775807
can't be represented exactly as a double:
double x = 9223372036854775807;
Common fixes
#If you need to use the exact value, then use the class BigInt
to represent the value:
var x = BigInt.parse('9223372036854775807');
If you need to use a double, then change the value to one that can be represented exactly:
double x = 9223372036854775808;
Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.