EN_raw_diagnostics_no_wildcard_variable_uses

  •                   Toolschevron_right
    
  •                   Diagnosticschevron_right
    
  •                   no_wildcard_variable_uses
    
                no_wildcard_variable_uses
    

Details about the 'no_wildcard_variable_uses' diagnostic produced by the Dart analyzer.

                more_vert
  •                       copyCopy link
    
  •                       bug_reportReport issue
    
                  toggle_on
                  Lint rule
    

The referenced identifier is a wildcard.

              Description

              #

              The analyzer produces this diagnostic when either a parameter or local
              variable whose name consists of only underscores is referenced. Such
              names became non-binding in Dart 3.7, making the reference illegal, so
              this will only appear in code for earlier language versions.

              Example

              #

              The following code produces this diagnostic because the name of the
              parameter consists of two underscores:

                dart
// @dart = 3.6
void f(int __) {
  print(__);
}
                content_copy

              The following code produces this diagnostic because the name of the
              local variable consists of a single underscore:

                dart
// @dart = 3.6
void f() {
  int _ = 0;
  print(_);
}
                content_copy

              Common fixes

              #

              If the variable or parameter is intended to be referenced, then give it a
              name that has at least one non-underscore character:

                dart
void f(int p) {
  print(p);
}
                content_copy

              If the variable or parameter is not intended to be referenced, then
              replace the reference with a different expression:

                dart
void f() {
  print(0);
}
                content_copy

Was this page's content helpful?

                    thumb_up
                    thumb_down

                Unless stated otherwise, the documentation on this site reflects Dart 3.13.3. Report an issue.