unnecessary_ primary_ constructor_ body
Details about the 'unnecessary_primary_constructor_body' diagnostic produced by the Dart analyzer.
Unnecessary primary constructor body.
Description
#The analyzer produces this diagnostic when a primary constructor body has no initializers, body, annotations, or documentation comment. Without these, the body is unnecessary.
Example
#The following code produces this diagnostic because the primary constructor body is unnecessary:
class C(final int i) {
this;
}
Common fixes
#Remove the primary constructor body:
class C(final int i);
Unless stated otherwise, the documentation on this site reflects Dart 3.12.2. Report an issue.