Skip to main content

Avoid unused parameters

Rule id

avoid-unused-parameters

Severity

Warning

Description

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

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

Example

Bad:

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

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

class SomeClass extends AnotherClass {
@override
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 {
@override
void method(String _) {}
}

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