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();
}
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.