DeepSource has joined Harness. Learn more
Dart Analyze logoDart Analyze/
DRT-W1633

Super invocation not at the end of initializer listDRT-W1633

Major severityMajor
Bug Risk categoryBug Risk

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);
}