avoid-missed-calls
added in: 1.3.0
warning
Warns when a method that should be invoked is passed as tear-off.
Example
❌ Bad:
class SomeClass {
final Future<void> Function() callback;
final void Function() regular;
final String Function() another;
const SomeClass({
required this.callback,
required this.regular,
required this.another,
});
}
void _handle() {
...
}
String _strHandle() => 'Dart Code Metrics';
void main() {
SomeClass(
callback: () async => _handle, // LINT
regular: () => _handle, // LINT
another: _strHandle,
);
}
✅ Good:
class SomeClass {
final Future<void> Function() callback;
final void Function() regular;
final String Function() another;
const SomeClass({
required this.callback,
required this.regular,
required this.another,
});
}
void _handle() {
...
}
String _strHandle() => 'Dart Code Metrics';
void main() {
SomeClass(
callback: () async => _handle(),
regular: () => _handle(),
another: _strHandle,
);
}