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:
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.7.3. Page last updated on 2025-05-08. View source or report an issue.