multiple_ primary_ constructor_ body_ declarations
Details about the 'multiple_primary_constructor_body_declarations' diagnostic produced by the Dart analyzer.
Only one primary constructor body declaration is allowed.
Description
#The analyzer produces this diagnostic when a class that declares a primary constructor also has more than one primary constructor body.
Example
#
The following code produces this diagnostic because the class C has more
than one primary constructor body:
class C(final int x) {
this : assert(x >= 0);
this : assert(x <= 0);
}
Common fixes
#Remove all but one of the primary constructor bodies, possibly by merging them:
class C(final int x) {
this : assert(x >= 0), assert(x <= 0);
}
Unless stated otherwise, the documentation on this site reflects Dart 3.11.0. Report an issue.