deprecated_consistency
Missing deprecated annotation.
This rule is available as of Dart 2.13.
Details
#DO apply @Deprecated()
consistently:
- if a class is deprecated, its constructors should also be deprecated.
- if a field is deprecated, the constructor parameter pointing to it should also be deprecated.
- if a constructor parameter pointing to a field is deprecated, the field should also be deprecated.
BAD:
dart
@deprecated
class A {
A();
}
class B {
B({this.field});
@deprecated
Object field;
}
GOOD:
dart
@deprecated
class A {
@deprecated
A();
}
class B {
B({@deprecated this.field});
@deprecated
Object field;
}
class C extends B {
C({@deprecated super.field});
}
Usage
#To enable the deprecated_consistency
rule,
add deprecated_consistency
under linter > rules in your
analysis_options.yaml
file:
analysis_options.yaml
yaml
linter:
rules:
- deprecated_consistency
除非另有说明,文档之所提及适用于 Dart 3.5.4 版本,本页面最后更新时间: 2024-08-02。 查看文档源码 或者 报告页面问题。