tearoff_ of_ generative_ constructor_ of_ abstract_ class
Details about the 'tearoff_of_generative_constructor_of_abstract_class' diagnostic produced by the Dart analyzer.
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:
abstract class C {
C();
}
void f() {
C.new;
}
Common fixes
#Tear off the constructor of a concrete class.
Unless stated otherwise, the documentation on this site reflects Dart 3.10.3. Report an issue.