Given this example, the linter should detect and issue on both cases, but only does it when not using the method reference.
class MyClass {
void refresh({@required String id});
}
class MyOtherClass {
final Function() onRefresh;
MyOtherClass(this.onRefresh);
}
void main() {
final a = MyClass();
// no lint issue
MyOtherClass(a.refresh);
// detects lint issue
MyOtherClass(() => a.refresh();
}
That's true. The analyzer doesn't detect when a function with a @required parameter is being passed to a location that expects a function without that required parameter. And I think it probably could.
However, given that null safety will include a required keyword and that the annotation will be deprecated at that point, I suspect that it isn't worth the effort to fix the issue with the annotation. And I confirmed that null safety semantics will catch both misuses of the method.
That's nice! Thanks for the clarification :)
Is the progress on the NNBD Linter tasks tracked somewhere?
I believe that the known linter issues related to Null Safety (the new name for NNBD) have been completed.
But just to be clear, the linter only implements the checks that are disabled by default. Both the checks for the @required annotation and the new required keyword are enabled by default, so they're implemented in the analyzer package. That work is being tracked in the sdk repository. I think they should all show up with this search: https://github.com/dart-lang/sdk/issues?q=is%3Aissue+is%3Aopen+label%3ANNBD.
Great!
Most helpful comment
That's true. The analyzer doesn't detect when a function with a
@requiredparameter is being passed to a location that expects a function without that required parameter. And I think it probably could.However, given that null safety will include a
requiredkeyword and that the annotation will be deprecated at that point, I suspect that it isn't worth the effort to fix the issue with the annotation. And I confirmed that null safety semantics will catch both misuses of the method.