private_ named_ parameter_ without_ public_ name
Details about the 'private_named_parameter_without_public_name' diagnostic produced by the Dart analyzer.
A private named parameter must be a public identifier after removing the leading underscore.
Description
#The analyzer produces this diagnostic when the name of a named parameter starts with an underscore and the result of removing the underscore isn't a valid public identifier.
Example
#
The following code produces this diagnostic because the named
parameter
_2legit without the _ is
2legit, which isn't a valid public identifier:
class C {
final int? _2legit;
C({this._2legit = 0});
int? get twoLegit => _2legit;
}
Common fixes
#Rename the parameter so that the character following the leading underscore is a letter.
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.