annotate_redeclares
Annotate redeclared members.
This rule is currently experimental and available as of Dart 3.2.
This rule has a quick fix available.
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:
dart
class C {
void f() { }
}
extension type E(C c) implements C {
void f() {
...
}
}
GOOD:
dart
import 'package:meta/meta.dart';
class C {
void f() { }
}
extension type E(C c) implements C {
@redeclare
void f() {
...
}
}
Usage
#To enable the annotate_redeclares
rule,
add annotate_redeclares
under linter > rules in your
analysis_options.yaml
file:
analysis_options.yaml
yaml
linter:
rules:
- annotate_redeclares
除非另有说明,文档之所提及适用于 Dart 3.5.4 版本,本页面最后更新时间: 2024-08-02。 查看文档源码 或者 报告页面问题。