cast_nullable_to_non_nullable

Group: style

Maturity: experimental

Linter v0.1.120

Since info is static, may be stale

View all Lint Rules

Using the Linter

Don't cast a nullable value to a non nullable type. This hides a null check and most of the time it is not what is expected.

BAD:

class A {}
class B extends A {}

A? a;
var v = a as B;
var v = a as A;

GOOD:

class A {}
class B extends A {}

A? a;
var v = a! as B;
var v = a!;