deprecated_new_in_comment_reference
Using the 'new' keyword in a comment reference is deprecated.
Description
#The analyzer produces this diagnostic when a comment reference (the name
of a declaration enclosed in square brackets in a documentation comment)
uses the keyword new
to refer to a constructor. This form is deprecated.
Examples
#The following code produces this diagnostic because the unnamed
constructor is being referenced using new C
:
/// See [new C].
class C {
C();
}
The following code produces this diagnostic because the constructor named
c
is being referenced using new C.c
:
/// See [new C.c].
class C {
C.c();
}
Common fixes
#If you're referencing a named constructor, then remove the keyword new
:
/// See [C.c].
class C {
C.c();
}
If you're referencing the unnamed constructor, then remove the keyword
new
and append .new
after the class name:
/// See [C.new].
class C {
C.c();
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。