findParent<T extends Component> method

T? findParent<T extends Component>()

Finds the closest parent further up the hierarchy that satisfies type=T, or null if none is found.

Implementation

T? findParent<T extends Component>() {
  return (parent is T ? parent : parent?.findParent<T>()) as T?;
}