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:
dart
class C {
C.a() : this.b();
}
Common fixes
#If the missing constructor must be called, then define it:
dart
class C {
C.a() : this.b();
C.b();
}
If the missing constructor doesn't need to be called, then remove the redirect:
dart
class C {
C.a();
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。