Skip to main content

avoid-unused-parameters

added in: 1.6.0
⚙️🛠

Checks for unused parameters inside a function or method body. For overridden methods suggests renaming unused parameters to _, __, etc.

warning

Abstract classes are completely ignored by the rule to avoid redundant checks for potentially overridden methods.

⚙️ Config

Set ignore-inline-functions (default is true) to ignore inline functions. Default value is set to true for backward compatibility and can be changed in the future.

dart_code_metrics:
...
rules:
...
- avoid-unused-parameters:
ignore-inline-functions: false

Example

❌ Bad:

void someFunction(String s) { // LINT
return;
}

class SomeClass {
void method(String s) { // LINT
return;
}
}

class SomeClass extends AnotherClass {

void method(String s) {} // LINT
}

✅ Good:

void someOtherFunction() {
return;
}

class SomeOtherClass {
void method() {
return;
}
}

void someOtherFunction(String s) {
print(s);
return;
}

class SomeOtherClass {
void method(String s) {
print(s);
return;
}
}

class SomeOtherClass extends AnotherClass {

void method(String _) {}
}

abstract class SomeOtherClass {
void method(String s);
}