unnecessary_type_name_in_constructor
Details about the 'unnecessary_type_name_in_constructor' diagnostic produced by the Dart analyzer.
Unnecessary type name in a constructor.
Description
#The analyzer produces this diagnostic when a secondary constructor declaration includes a type name.
Examples
#The following code produces this diagnostic because the generative constructor declaration includes the type name:
class C {
C();
}
The following code produces this diagnostic because the factory constructor declaration includes the type name:
class C {
factory C() => C._();
new _() {}
}
Common fixes
#Remove the type name from the constructor. If the constructor is named, also remove the period before the name:
class C {
new ();
}
or
class C {
factory () => C._();
new _() {}
}
除非另有说明,文档之所提及适用于 Dart 3.11.0 版本报告页面问题.