castOrNull<T> method

T? castOrNull<T>()

Cast the object only if it is the type specified if it's not, just return null

Implementation

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