Skip to main content

avoid-unnecessary-overrides

effort: 2m
has auto-fix
starter+

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 {

// LINT: This override is unnecessary as it does not change the signature and does not add implementation. Try removing it.
String get field;


// LINT: This override is unnecessary as it does not change the signature and does not add implementation. Try removing it.
Future<void> foo();
}

mixin M on B {

// LINT: This override is unnecessary as it does not change the signature and does not add implementation. Try removing it.
String get field;
}

✅ Good:

abstract class B {
String get field;

void foo();
}

class C extends B {

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


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