deprecated_consistency
Missing deprecated annotation.
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});
}
Enable
#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
If you're instead using the YAML map syntax to configure linter rules, add deprecated_consistency: true
under linter > rules:
analysis_options.yaml
yaml
linter:
rules:
deprecated_consistency: 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.