Skip to main content

avoid-unnecessary-declaring-parameters

effort: 2m
dart 3.13+
has IDE fix
has auto-fix
pro+

Suggests converting a declaring parameter to a regular parameter when it's not used outside of the primary constructor.

Example​

❌ Bad:

// LINT: This declaring parameter can be converted to a regular parameter as it is not used outside the constructor.
// Try removing the 'final' keyword.
class Primary(final String _value) {
final another = _value;

final String third;

this : third = _value;
}

✅ Good:

class Primary(String _value) {
final another = _value;

final String third;

this : third = _value;
}

class Another(final String _value) {
void fn() {
print(_value);
}
}