matching_super_parameters
Use matching super parameter names.
Details
#DO use super parameter names that match their corresponding super constructor's parameter names.
BAD:
dart
class Rectangle {
final int width;
final int height;
Rectangle(this.width, this.height);
}
class ColoredRectangle extends Rectangle {
final Color color;
ColoredRectangle(
this.color,
super.height, // Bad, actually corresponds to the `width` parameter.
super.width, // Bad, actually corresponds to the `height` parameter.
);
}
GOOD:
dart
class Rectangle {
final int width;
final int height;
Rectangle(this.width, this.height);
}
class ColoredRectangle extends Rectangle {
final Color color;
ColoredRectangle(
this.color,
super.width,
super.height,
);
}
Enable
#To enable the matching_super_parameters
rule, add matching_super_parameters
under linter > rules in your analysis_options.yaml
file:
analysis_options.yaml
yaml
linter:
rules:
- matching_super_parameters
If you're instead using the YAML map syntax to configure linter rules, add matching_super_parameters: true
under linter > rules:
analysis_options.yaml
yaml
linter:
rules:
matching_super_parameters: true
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-03-07. View source or report an issue.