Skip to content

Files

Latest commit

 

History

History
48 lines (35 loc) · 972 Bytes

avoid_final_parameters.md

File metadata and controls

48 lines (35 loc) · 972 Bytes

Pattern: Use of final parameter

Issue: -

Description

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

Further Reading