super_formal_parameter_without_associated_named
No associated named super constructor parameter.
Description
#The analyzer produces this diagnostic when there's a named super parameter in a constructor and the implicitly or explicitly invoked super constructor doesn't have a named parameter with the same name.
Named super parameters are associated by name with named parameters in the super constructor.
Example
#The following code produces this diagnostic because the constructor in A
doesn't have a parameter named y
:
class A {
A({int? x});
}
class B extends A {
B({super.y});
}
Common fixes
#If the super parameter should be associated with an existing parameter from the super constructor, then change the name to match the name of the corresponding parameter:
class A {
A({int? x});
}
class B extends A {
B({super.x});
}
If the super parameter should be associated with a parameter that hasn't yet been added to the super constructor, then add it:
class A {
A({int? x, int? y});
}
class B extends A {
B({super.y});
}
If the super parameter doesn't correspond to a named parameter from the super constructor, then change it to be a normal parameter:
class A {
A({int? x});
}
class B extends A {
B({int? y});
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。