tighten_type_of_initializing_formals

Group: style

Maturity: stable

Dart SDK: >= 2.11.0-182.0.dev • (Linter v0.1.120)

Since info is static, may be stale

View all Lint Rules

Using the Linter

Tighten type of initializing formal if a non-null assert exists. This allows the type system to catch problems rather than have them only be caught at run-time.

BAD:

class A {
  A.c1(this.p) : assert(p != null);
  A.c2(this.p);
  final String? p;
}

GOOD:

class A {
  A.c1(String this.p) : assert(p != null);
  A.c2(this.p);
  final String? p;
}