Skip to content

super_call_written_out

Reports super() with no arguments in a constructor’s initializer list. Delete it: the constructor calls it anyway.

Tier
advisory
Scope
Dart
Lowest preset
recommended
Fix
deletes the call with the colon or comma before it

super() in a constructor’s initializer list: a call of the unnamed superclass constructor with no arguments. The violation covers the call.

It does not report:

  • super(key) or any call with arguments, even where they equal the defaults;
  • super.named();
  • a call of a member through super, such as super.save(). Without super. it would call the member of the object’s own class, which a subclass may override.

A constructor that calls no other constructor calls that one anyway.

Violating
class Plain {
Plain() : super();
}
Corrected
class Plain {
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: assay/super_call_written_out

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