redirect_ generative_ to_ missing_ constructor
The constructor '{0}' couldn't be found in '{1}'.
Description
#The analyzer produces this diagnostic when a generative constructor redirects to a constructor that isn't defined.
Example
#
The following code produces this diagnostic because the constructor
C.a
redirects to the constructor
C.b
, but
C.b
isn't defined:
class C {
C.a() : this.b();
}
Common fixes
#If the missing constructor must be called, then define it:
class C {
C.a() : this.b();
C.b();
}
If the missing constructor doesn't need to be called, then remove the redirect:
class C {
C.a();
}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-1. View source or report an issue.