I am learning dart programming language version 2.14.3 and came across an odd issue that I am unable to understand.
The following code doesn't compile obviously because isEven is only defined in int class.
void main() {
const num someNumber = 3;
print(someNumber.isEven);
}
However, casting someNumber to int and assigning the value to a different variable, solved the problem and the code compiles with print(someNumber.isEven); not changed. The following code compiles.
void main() {
const num someNumber = 3;
final someInt = someNumber as int;
print(someNumber.isEven);
}
Is this a bug in dart or a language feature that I am not aware of?