Pattern: Use of final
parameter
Issue: -
AVOID declaring parameters as final.
Declaring parameters as final can lead to unecessarily verbose code, especially when using the "parameter_assignments" rule.
Example of correct code:
void badParameter(String label) { // OK
print(label);
}
Example of incorrect code:
void goodParameter(final String label) { // LINT
print(label);
}
Example of correct code:
void badExpression(int value) => print(value); // OK
Example of incorrect code:
void goodExpression(final int value) => print(value); // LINT
Example of correct code:
[1, 4, 6, 8].forEach((value) => print(value + 2)); // OK
Example of incorrect code:
[1, 4, 6, 8].forEach((final value) => print(value + 2)); // LINT