跳到主要内容

void_checks

稳定
核心

不要赋值给 void

详情

#

不要赋值给 void

错误示例

dart
class A<T> {
  T value;
  void test(T arg) { }
}

void main() {
  A<void> a = A<void>();
  a.value = 1; // LINT
  a.test(1); // LINT
}

启用

#

要启用 void_checks 规则,请在您的 analysis_options.yaml 文件中的 linter > rules 下添加 void_checks

analysis_options.yaml
yaml
linter:
  rules:
    - void_checks

如果您改为使用 YAML 映射语法来配置 linter 规则,请在 linter > rules 下添加 void_checks: true

analysis_options.yaml
yaml
linter:
  rules:
    void_checks: true