Skip to main content

implicit_super_initializer_missing_arguments

The implicitly invoked unnamed constructor from '{0}' has required parameters.

Description

#

The analyzer produces this diagnostic when a constructor implicitly invokes the unnamed constructor from the superclass, the unnamed constructor of the superclass has a required parameter, and there's no super parameter corresponding to the required parameter.

Examples

#

The following code produces this diagnostic because the unnamed constructor in the class B implicitly invokes the unnamed constructor in the class A, but the constructor in A has a required positional parameter named x:

dart
class A {
  A(int x);
}

class B extends A {
  B();
}

The following code produces this diagnostic because the unnamed constructor in the class B implicitly invokes the unnamed constructor in the class A, but the constructor in A has a required named parameter named x:

dart
class A {
  A({required int x});
}

class B extends A {
  B();
}

Common fixes

#

If you can add a parameter to the constructor in the subclass, then add a super parameter corresponding to the required parameter in the superclass' constructor. The new parameter can either be required:

dart
class A {
  A({required int x});
}

class B extends A {
  B({required super.x});
}

or it can be optional:

dart
class A {
  A({required int x});
}

class B extends A {
  B({super.x = 0});
}

If you can't add a parameter to the constructor in the subclass, then add an explicit super constructor invocation with the required argument:

dart
class A {
  A(int x);
}

class B extends A {
  B() : super(0);
}