$cast<T> function

T? $cast<T>(
  1. dynamic value
)

Returns T if instance of T, otherwise null

Implementation

T? $cast<T>(value) => value == null
    ? null
    : value is T
        ? value
        : null;