I get the following error.
The argument type 'dynamic' can't be assigned to the parameter type '() -> dynamic'
The example is:
outerFunc(somevar) {
return () {....}
}
anOtherFunction(func()) {....}
anOtherFunction(outerFunc('test'));
These occurs when I return an anonymous function, in strong mode with the analysis_options.yaml on.
strong-mode:
implicit-casts: false
outerFunc doesn't specify a return type, therefore dynamic is assumed.
You can create a typedef and use it as return type for outerFunc.
The function type can't be inferred from the return statement.
typedef dynamic F();
F outerFunc(somevar) {
return () {};
}
You can also write the function type in-line
dynamic Function() outerFunc(somevar) {
return () {};
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With