Skip to content

extends_object_written_out

Reports extends Object on a class and on Object on a mixin. Delete the clause.

Tier
advisory
Scope
Dart
Lowest preset
recommended
Fix
deletes the clause

extends Object on a class and on Object on a mixin, where Object is that of dart:core. The violation is on the clause.

It does not report:

  • the bound Object? of a type parameter. Without a bound, a type parameter becomes dynamic where a type argument is left out; with that bound it becomes Object?, so the two are not the same.
  • the bound Object;
  • a class named Object declared in your own code.

Every class extends Object and every mixin applies to it, so the clause says nothing.

Violating
class Plain extends Object {}
Corrected
class Plain {}

Set under the assay: key of the project’s root analysis_options.yaml.

Rule parameter Default Effect
enabled true false switches the rule off for the whole project.
exclude [] Path globs where the rule is silent.

Write why on the line directly above the suppression:

// Why it stays as written here.
// ignore: extends_object_written_out

// ignore_for_file: assay/extends_object_written_out silences it in a whole file, and // ignore: assay/extends_object_written_out with the prefix works too. See Suppressions.