Skip to main content

avoid-unnecessary-overrides

added in: 1.22.0
🛠
Pro+
preset: recommended

Warns when a parent declaration is overridden by a declaration without an implementation.

Example

❌ Bad:

abstract class B {
String get field;

void foo();
}

abstract class A extends B {

String get field; // LINT: Unnecessary override. Try removing it.


Future<void> foo(); // LINT: Unnecessary override. Try removing it.
}

mixin M on B {

String get field; // LINT: Unnecessary override. Try removing it.
}

✅ Good:

abstract class B {
String get field;

void foo();
}

class C extends B {

String get field => 'hi'; // Correct, has implementation


Future<void> foo() async { ... }
}