如何禁用警告 "Omit type annotations for local variables"?在 Dart 中(带有 Pedantic 包)

How to disable the warning "Omit type annotations for local variables"? in Dart (with Pedantic Package)

我在 Flutter 中使用 pedantic 包,我有以下 anaylsis_options.yaml 文件:

include: package:pedantic/analysis_options.yaml # advanced linter

analyzer:
  enable-experiment:
    - extension-methods

linter:
  rules:
    omit_local_variables_types: false
    # always_specify_types: true

我尝试禁用 "Omit type annotations for local variables" 警告。我只能禁用它,我取消注释最后一行(参见问题 )。但我不想指定每种类型。所以这不是我想要的。

那么如何全局禁用此警告?

我不确定这个功能是否晚于发布问题时出现,但根据 here 您可以忽略规则。

因此,如果您想禁用 omit_local_variable_types 规则的警告,您可以在 anaylsis_options.yaml 文件中执行以下操作:

analyzer:
  errors:
    omit_local_variable_types: ignore