private_ named_ non_ field_ parameter
                  Named parameters that don't refer to instance variables can't start with underscore.
Description
#The analyzer produces this diagnostic when a named parameter starts with an underscore, unless it's an initializing formal or field parameter.
Example
#
                    The following code produces this diagnostic because the named parameter
                    _x starts with an underscore:
                  
class C {
  C({int _x = 0});
}
                      
                      
                      
                    Common fixes
#If the parameter is intended to refer to a field, then add the missing field:
class C {
  final int _x;
  C({this._x = 0});
  int get x => _x;
}
                      
                      
                      
                    If the parameter isn't intended to refer to a field, then remove the underscore:
class C {
  C({int x = 0});
}
                      
                      
                      
                    Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-11-4. View source or report an issue.