undefined_constructor_in_initializer
The class '{0}' doesn't have a constructor named '{1}'.
The class '{0}' doesn't have an unnamed constructor.
Description
#The analyzer produces this diagnostic when a superclass constructor is invoked in the initializer list of a constructor, but the superclass doesn't define the constructor being invoked.
Examples
#The following code produces this diagnostic because A
doesn't have an unnamed constructor:
class A {
A.n();
}
class B extends A {
B() : super();
}
The following code produces this diagnostic because A
doesn't have a constructor named m
:
class A {
A.n();
}
class B extends A {
B() : super.m();
}
Common fixes
#If the superclass defines a constructor that should be invoked, then change the constructor being invoked:
class A {
A.n();
}
class B extends A {
B() : super.n();
}
If the superclass doesn't define an appropriate constructor, then define the constructor being invoked:
class A {
A.m();
A.n();
}
class B extends A {
B() : super.m();
}
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.