DeepSource has joined Harness. Learn more
Dart Analyze logoDart Analyze/
DRT-W1085

Missing deprecated annotationDRT-W1085

Major severityMajor
Anti-pattern categoryAnti-pattern

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});
}