Skip to main content

avoid-unnecessary-extends

added in: 1.22.0
🛠
Pro+

Suggests removing unnecessary extends clauses that match default values for classes and type parameters.

In Dart, all classes by default extend Object and all type parameters extend Object?. Removing those extends clauses will not affect your code.

Additional resources:

Example

❌ Bad:

class Base {}

class Subclass extends Object {} // LINT

class Another extends Base {}

// LINT
class WithTypeParam<T extends Object?, B extends Object> {}

✅ Good:

class Base {}

class Subclass extends Base {}

class Another extends Base {}

class WithTypeParam<T extends Object, B extends Object> {}