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:
@deprecated
class A {
A();
}
class B {
B({this.field});
@deprecated
Object field;
}
GOOD:
@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:
linter:
rules:
- deprecated_consistency
If you're instead using the YAML map syntax to configure linter rules,
add
deprecated_consistency: true
under
linter > rules:
linter:
rules:
deprecated_consistency: true
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Report an issue.