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
:
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
:
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:
class A {
A({required int x});
}
class B extends A {
B({required super.x});
}
or it can be optional:
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:
class A {
A(int x);
}
class B extends A {
B() : super(0);
}
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.