annotate_overrides
Annotate overridden members.
Details
#DO annotate overridden methods and fields.
This practice improves code readability and helps protect against unintentionally overriding superclass members.
BAD:
dart
class Cat {
int get lives => 9;
}
class Lucky extends Cat {
final int lives = 14;
}
GOOD:
dart
abstract class Dog {
String get breed;
void bark() {}
}
class Husky extends Dog {
@override
final String breed = 'Husky';
@override
void bark() {}
}
Enable
#To enable the annotate_overrides
rule, add annotate_overrides
under linter > rules in your analysis_options.yaml
file:
analysis_options.yaml
yaml
linter:
rules:
- annotate_overrides
If you're instead using the YAML map syntax to configure linter rules, add annotate_overrides: true
under linter > rules:
analysis_options.yaml
yaml
linter:
rules:
annotate_overrides: 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.