Group: style
Maturity: stable
Dart SDK: >= 2.16.0 • (Linter v1.15.0)
Since info is static, may be staleAVOID declaring parameters as final.
Declaring parameters as final can lead to unnecessarily verbose code, especially when using the "parameter_assignments" rule.
BAD:
void goodParameter(final String label) { // LINT
print(label);
}
GOOD:
void badParameter(String label) { // OK
print(label);
}
BAD:
void goodExpression(final int value) => print(value); // LINT
GOOD:
void badExpression(int value) => print(value); // OK
BAD:
[1, 4, 6, 8].forEach((final value) => print(value + 2)); // LINT
GOOD:
[1, 4, 6, 8].forEach((value) => print(value + 2)); // OK
Incompatible with: prefer_final_parameters.
To enable the avoid_final_parameters
lint,
add avoid_final_parameters
under linter > rules in your
analysis_options.yaml
file:
linter:
rules:
- avoid_final_parameters