multiple_redirecting_constructor_invocations
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
:
dart
class C {
C() : this.a(), this.b();
C.a();
C.b();
}
Common fixes
#Remove all but one of the redirections:
dart
class C {
C() : this.a();
C.a();
C.b();
}
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.