int and double equality with const in Dart

Viewed 174

If I do

final x = (2 == 2.0);

Then x is true.

But if I do

const x = (2 == 2.0);

Then x is false.

I would expect both to be true based on the docs:

If one operand is a double and the other is an int, they are equal if the double has an integer value (finite with no fractional part) and identical(doubleValue.toInt(), intValue) is true.

What's going on here?

0 Answers
Related