Closed
Description
- Dart SDK Version: 2.0.0-dev.43.0
- macOS
Considering a simple function like this:
add(int a, int b) {
return a + b;
}
VSCode(with Dart extension) tells me the return type of add
function is dynamic
:
add(int a, int b) → dynamic
But if we add a wrong type, like
String add(int a, int b) {
return a + b;
}
Then it shows an error:
[dart] The return type 'int' isn't a 'String', as defined by the method 'add'.
Obviously the compiler knows the return value is a int
, but if we don't declare it explicitly, it will be a dynamic
. Is it by design?