Skip to content

Files

Latest commit

 

History

History
42 lines (29 loc) · 871 Bytes

no_wildcard_variable_uses.md

File metadata and controls

42 lines (29 loc) · 871 Bytes

Pattern: Use of wildcard variable

Issue: -

Description

DON'T use wildcard parameters or variables.

Wildcard parameters and local variables (e.g. underscore-only names like _, __, ___, etc.) will become non-binding in a future version of the Dart language. Any existing code that uses wildcard parameters or variables will break. In anticipation of this change, and to make adoption easier, this lint disallows wildcard and variable parameter uses.

Example of incorrect code:

var _ = 1;
print(_); // LINT
void f(int __) {
 print(__); // LINT multiple underscores too
}

Example of correct code:

for (var _ in [1, 2, 3]) count++;
var [a, _, b, _] = [1, 2, 3, 4];

Further Reading