asOrNull<T> method

T? asOrNull<T>()

asOrNull: Attempts to cast the object to a specified type, returning null if the cast fails.

Implementation

T? asOrNull<T>() {
  return this is T ? this as T : null;
}