no_wildcard_variable_uses
Don't use wildcard parameters or variables.
此规则自 Dart 3.1 版本起可用。
_规则集:core , recommended , flutter _
详情
#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.
BAD:
var _ = 1;
print(_); // LINT
void f(int __) {
print(__); // LINT multiple underscores too
}
GOOD:
for (var _ in [1, 2, 3]) count++;
var [a, _, b, _] = [1, 2, 3, 4];
使用方法
#要启用 no_wildcard_variable_uses
规则,请在你的 analysis_options.yaml
文件中,在 linter > rules 下添加 no_wildcard_variable_uses
:
linter:
rules:
- no_wildcard_variable_uses
除非另有说明,否则本网站上的文档反映的是 Dart 3.6.0。页面最后更新于 2025-02-05。 查看源代码 或 报告问题.