unnecessary_ final
Details about the 'unnecessary_final' diagnostic produced by the Dart analyzer.
The keyword 'final' isn't necessary because the parameter is implicitly 'final'.
Description
#
The analyzer produces this diagnostic when either a field initializing
parameter or a super parameter in a constructor has the keyword final.
In both cases the keyword is unnecessary because the parameter is
implicitly final.
Examples
#
The following code produces this diagnostic because the field initializing
parameter has the keyword final:
class A {
int value;
A(final this.value);
}
The following code produces this diagnostic because the super parameter in
B has the keyword final:
class A {
A(int value);
}
class B extends A {
B(final super.value);
}
Common fixes
#Remove the unnecessary final keyword:
class A {
A(int value);
}
class B extends A {
B(super.value);
}
Unless stated otherwise, the documentation on this site reflects Dart 3.10.3. Report an issue.