Override only forwards to the superclass member

ID

dart.maintainability.unnecessary_overrides

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Redundant Code

Language

Dart

Description

Reports an @override member whose entire body forwards to the superclass member of the same name with the same arguments - void dispose() ⇒ super.dispose();, the equivalent block or return form, or a getter returning super.<name>. Overrides that change the arguments, add statements, or wrap the result are not reported.

Rationale

The override changes nothing: removing it leaves the inherited member doing exactly the same work. What it does change is the reading of the class. A reader who sees @override assumes the behaviour differs and has to compare both bodies to find that it does not, and every such member is one more place to keep in step when the superclass signature moves. It also hides the interesting overrides among the ones that do nothing.

The following code illustrates the pattern detected by this rule:

class Widgetish {
  void refresh() {}
  void dispose() {}
  int compute(int x) => x;
  String join(String a, String b) => a + b;
  int describe(int x) => x;
  String label(String a, String b) => a + b;
  int get total => 1;
  int get depth => 2;
  void reset() {}
}

class Panel extends Widgetish {
  // FLAGGED: Override only forwards to the superclass member
  @override
  void refresh() => super.refresh();
}

Remediation

Delete the member and let the class inherit it. Keep it only if it exists for a reason the body does not show - to narrow the return type, to attach documentation, or to widen the visibility of an inherited member - and if so, say so in a doc comment.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved