private_ named_ parameter_ without_ public_ name
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.
Unless stated otherwise, the documentation on this site reflects Dart 3.10.3. Page last updated on 2025-12-5. View source or report an issue.