annotate_redeclares
Annotate redeclared members.
Details
#DO annotate redeclared members.
This practice improves code readability and helps protect against unintentionally redeclaring members or being surprised when a member ceases to redeclare (due for example to a rename refactoring).
BAD:
class C {
void f() { }
}
extension type E(C c) implements C {
void f() {
...
}
}
GOOD:
import 'package:meta/meta.dart';
class C {
void f() { }
}
extension type E(C c) implements C {
@redeclare
void f() {
...
}
}
Enable
#To enable the annotate_redeclares
rule, add annotate_redeclares
under linter > rules in your analysis_options.yaml
file:
linter:
rules:
- annotate_redeclares
If you're instead using the YAML map syntax to configure linter rules, add annotate_redeclares: true
under linter > rules:
linter:
rules:
annotate_redeclares: true
Unless stated otherwise, the documentation on this site reflects Dart 3.6.2. Page last updated on 2025-01-27. View source or report an issue.