castOrNull<T> function Null safety

T? castOrNull<T>(
  1. dynamic x
)

Implementation

T? castOrNull<T>(x) => x is T ? x : null;