type_init_formals

Group: style

Maturity: stable

Linter v0.1.1

Since info is static, may be stale
recommendedflutterpedantic

View all Lint Rules

Using the Linter

From the style guide:

DON'T type annotate initializing formals.

If a constructor parameter is using this.x to initialize a field, then the type of the parameter is understood to be the same type as the field. If a a constructor parameter is using super.x to forward to a super constructor, then the type of the parameter is understood to be the same as the super constructor parameter.

Type annotating an initializing formal with a different type than that of the field is OK.

GOOD:

class Point {
  int x, y;
  Point(this.x, this.y);
}

BAD:

class Point {
  int x, y;
  Point(int this.x, int this.y);
}

GOOD:

class A {
  int a;
  A(this.a);
}

class B extends A {
  B(super.a);
}

BAD:

class A {
  int a;
  A(this.a);
}

class B extends A {
  B(int super.a);
}