Skip to content

avoid_unnecessary_extends

v1.0.0 Warning Code Organization

Flags a class that explicitly extends dart:core’s Object.

Every Dart class extends Object already, so the clause states the default while looking like a decision. A reader who sees an extends expects the superclass to matter, and has to recall that this one does not.

This rule is in the opinionated preset, so it is on with preset: opinionated or preset: pedantic.

See also: Object

class UserRepository extends Object {
Future<void> refresh() async {}
}
class UserRepository {
Future<void> refresh() async {}
}

The rule resolves the type rather than matching the name, so a class extending a locally declared Object is making a genuine choice and is left alone:

// Accepted — this `Object` is not dart:core's
class Object {
void describe() {}
}
class Node extends Object {}

No quick fix. Deleting the clause is safe, but the rename that introduced it is often mid-migration, and the author is better placed to say whether the base class is coming back.

To disable this rule:

many_lints.yaml
rules:
avoid_unnecessary_extends: false

To keep the rule on but skip certain paths, use per-rule exclude.