Skip to main content

avoid_final_parameters

Details about the 'avoid_final_parameters' diagnostic produced by the Dart analyzer.

Parameters should not be marked as 'final'.

Description

#

The analyzer produces this diagnostic when a parameter declaration is marked with the final keyword.

Examples

#

The following code produces this diagnostic because the parameter a is marked as final:

dart
void f(final String a) {
  print(a);
}

The following code produces this diagnostic because the closure parameter a is marked as final:

dart
var f = (final int a) => print(a);

Common fixes

#

Remove the final keyword from the parameter declaration:

dart
void f(String a) {
  print(a);
}
dart
var f = (int a) => print(a);