call_method_written_out
Reports a function value called through its call method, such as onDone.call(result). Call the function itself.
- Tier
- advisory
- Scope
- Dart
- Lowest preset
- recommended
- Fix
- deletes
.call
What it reports
Section titled “What it reports”A call that names the call method of a value of a function type: onDone.call(result).
It does not report:
?.call, which has no shorter form;- a cascade;
- a value of the type
Functionordynamic; - a
callof an extension; - an object whose class declares a
callmethod, such asloginUseCase.call(params)or a code builder’srefer('print').call([]). Therecallnames what the object does, and writing it says that an object is called.
A function is called by writing its arguments after it. .call says nothing more, and makes the reader look for a method that is not there.
Example
Section titled “Example”Violating
void finish(void Function(int) onDone) => onDone.call(1);Corrected
void finish(void Function(int) onDone) => onDone(1);Rule parameters
Section titled “Rule parameters”Set under the assay: key of the project’s root analysis_options.yaml.
| Rule parameter | Default | Effect |
|---|---|---|
enabled |
true |
false switches the rule off for the whole project. |
exclude |
[] |
Path globs where the rule is silent. |
Suppressing it
Section titled “Suppressing it”Write why on the line directly above the suppression:
// The generated client documents this callback by its call method.// ignore: assay/call_method_written_out// ignore_for_file: assay/call_method_written_out silences it in a whole file, and // ignore: call_method_written_out without the prefix works too. See Suppressions.