Skip to main content

avoid-unnecessary-call

added in: 1.7.0
🛠
Pro+
preset: recommended

Warns when a .call() invocation is unnecessary and can be simplified.

Example

❌ Bad:

class SomeClass {
void call() {
...
}
}

final instance = SomeClass();
instance.call(); // LINT: This invocation is unnecessary and can be simplified. Try removing it.

✅ Good:

class SomeClass {
void call() {
...
}
}

final instance = SomeClass();
instance();