tearoff_of_generative_constructor_of_abstract_class
A generative constructor of an abstract class can't be torn off.
Description
#The analyzer produces this diagnostic when a generative constructor from an abstract class is being torn off. This isn't allowed because it isn't valid to create an instance of an abstract class, which means that there isn't any valid use for the torn off constructor.
Example
#The following code produces this diagnostic because the constructor C.new
is being torn off and the class C
is an abstract class:
dart
abstract class C {
C();
}
void f() {
C.new;
}
Common fixes
#除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。