duplicate_ignore
The diagnostic '{0}' doesn't need to be ignored here because it's already being ignored.
Description
#The analyzer produces this diagnostic when a diagnostic name appears in an
ignore
comment, but the diagnostic is already being ignored, either
because it's already included in the same ignore
comment or because it
appears in an ignore-in-file
comment.
Examples
#The following code produces this diagnostic because the diagnostic named
unused_local_variable
is already being ignored for the whole file so it
doesn't need to be ignored on a specific line:
// ignore_for_file: unused_local_variable
void f() {
// ignore: unused_local_variable
var x = 0;
}
The following code produces this diagnostic because the diagnostic named
unused_local_variable
is being ignored twice on the same line:
void f() {
// ignore: unused_local_variable, unused_local_variable
var x = 0;
}
Common fixes
#Remove the ignore comment, or remove the unnecessary diagnostic name if the ignore comment is ignoring more than one diagnostic:
// ignore_for_file: unused_local_variable
void f() {
var x = 0;
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。