super_invocation_not_last
(Previously known as invalid_super_invocation
)
The superconstructor call must be last in an initializer list: '{0}'.
Description
#The analyzer produces this diagnostic when the initializer list of a constructor contains an invocation of a constructor in the superclass, but the invocation isn't the last item in the initializer list.
Example
#The following code produces this diagnostic because the invocation of the superclass' constructor isn't the last item in the initializer list:
dart
class A {
A(int x);
}
class B extends A {
B(int x) : super(x), assert(x >= 0);
}
Common fixes
#Move the invocation of the superclass' constructor to the end of the initializer list:
dart
class A {
A(int x);
}
class B extends A {
B(int x) : assert(x >= 0), super(x);
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。