You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the web, when compiled to JavaScript, all numbers are JavaScript numbers — which means that they are all doubles.
Even integers are represented by JavaScript numbers, so 1 and 1.0 is the exact same object, which is then treated as if it was an instance of a class which implements both intanddouble.
On native, 1 and 1.0 are different objects and instances of different classes.
The initialization dynamic integerValue = 1; treats 1 as an integer literal because it's not in a double context. That makes it an integer value on native, and the implicit integerValue as double? fails.
On the web, dynamic integerValue = 1; also treats 1 as an integer literal, which happens to evaluate to the same object as 1.0.
When you do the the integerValue as double? which is implicit in the downcast in the assignment, the web runtime system checks whether the value, 1 aka 1.0, implements double?, and it is (also) a double so the case succeeds.
From dart-lang/language#20 and #34355
On windows I get
type 'int' is not a subtype of type 'double?'
.On web I got no errors.
Dart SDK version: 2.14.0-383.0.dev on "windows_x64"
The text was updated successfully, but these errors were encountered: