unnecessary_ primary_ constructor_ body
Learn about the unnecessary_primary_constructor_body linter rule.
Unnecessary primary constructor bodies can be removed.
Details
#Don't include an empty primary constructor body.
BAD:
class C() {
this;
}
GOOD:
class C();
Enable
#
To enable the unnecessary_primary_constructor_body rule, add unnecessary_primary_constructor_body
under
linter > rules in your analysis_options.yaml
file:
linter:
rules:
- unnecessary_primary_constructor_body
If you're instead using the YAML map syntax to configure linter rules,
add unnecessary_primary_constructor_body: true under linter > rules:
linter:
rules:
unnecessary_primary_constructor_body: true
Unless stated otherwise, the documentation on this site reflects Dart 3.12.2. Report an issue.