unnecessary_ final
Details about the 'unnecessary_final' diagnostic produced by the Dart analyzer.
Local variables should not be marked as 'final'.
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:
// @dart = 3.10
class A {
int value;
A(final this.value);
}
The following code produces this diagnostic because the super
parameter in
B has the keyword final:
// @dart = 3.10
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);
}
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.