Dart Analyze logoDart Analyze/
DRT-W1439

Super parameters can only be used in non-redirecting generative constructorsDRT-W1439

Major severityMajor
Bug Risk categoryBug Risk

The analyzer produces this diagnostic when a super parameter is used anywhere other than a non-redirecting generative constructor.

Examples

The following code produces this diagnostic because the super parameter x is in a redirecting generative constructor:

class A {
  A(int x);
}

class B extends A {
  B.b(super.x) : this._();
  B._() : super(0);
}

The following code produces this diagnostic because the super parameter x isn't in a generative constructor:

class A {
  A(int x);
}

class C extends A {
  factory C.c(super.x) => C._();
  C._() : super(0);
}

The following code produces this diagnostic because the super parameter x is in a method:

class A {
  A(int x);
}

class D extends A {
  D() : super(0);

  void m(super.x) {}
}

Common fixes

If the function containing the super parameter can be changed to be a non-redirecting generative constructor, then do so:

class A {
  A(int x);
}

class B extends A {
  B.b(super.x);
}

If the function containing the super parameter can't be changed to be a non-redirecting generative constructor, then remove the super:

class A {
  A(int x);
}

class D extends A {
  D() : super(0);

  void m(int x) {}
}