multiple_ redirecting_ constructor_ invocations
Details about the 'multiple_redirecting_constructor_invocations' diagnostic produced by the Dart analyzer.
Constructors can have only one 'this' redirection, at most.
Description
#
The analyzer produces this diagnostic when a constructor
redirects to more than one other constructor in the same class
(using this).
Example
#
The following code produces this diagnostic because the
unnamed constructor in C is redirecting to both
this.a and this.b:
class C {
C() : this.a(), this.b();
C.a();
C.b();
}
Common fixes
#Remove all but one of the redirections:
class C {
C() : this.a();
C.a();
C.b();
}
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.