findParent<T extends Component> method

T? findParent<T extends Component>({
  1. bool includeSelf = false,
})

Returns the closest parent further up the hierarchy that satisfies type=T, or null if no such parent can be found.

If includeSelf is set to true (default is false) then the component which the call is made for is also included in the search.

Implementation

T? findParent<T extends Component>({bool includeSelf = false}) {
  return ancestors(includeSelf: includeSelf).whereType<T>().firstOrNull;
}