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:
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:
class A {
A(int x);
}
class B extends A {
B(int x) : assert(x >= 0), super(x);
}
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.