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 {}}Examples
Section titled “Examples”A shadowing Object is a real superclass
Section titled “A shadowing Object is a real superclass”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'sclass Object { void describe() {}}
class Node extends Object {}Known limitations
Section titled “Known limitations”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.
Turning this rule off
Section titled “Turning this rule off”To disable this rule:
rules: avoid_unnecessary_extends: falseTo keep the rule on but skip certain paths, use per-rule exclude.
Related rules
Section titled “Related rules”arguments_ordering— Keep named arguments in a configured order.avoid_duplicate_mixins— Flag a mixin applied twice in onewithclause.avoid_generics_shadowing— Avoid generic type parameters that shadow top-level declarations.avoid_unnecessary_constructor— Remove a constructor identical to the default one.