use_ declaring_ parameters
Details about the 'use_declaring_parameters' diagnostic produced by the Dart analyzer.
Use a declaring parameter.
Description
#The analyzer produces this diagnostic when a primary constructor has a parameter whose name matches a field of the same type in the class, and the constructor assigns the value to the field without modifying it.
Example
#
The following code produces this diagnostic because the constructor
assigns the parameter i to the field i:
class C(int i) {
final int i;
this : i = i;
}
Common fixes
#Convert the parameter to a declaring parameter:
class C(final int i);
Unless stated otherwise, the documentation on this site reflects Dart 3.12.2. Report an issue.