findAncestorComponentOfType<T extends Component> method

  1. @override
T? findAncestorComponentOfType<T extends Component>()
override

Implementation

@override
T? findAncestorComponentOfType<T extends Component>() {
  var ancestor = _parent;
  while (ancestor != null && ancestor.component.runtimeType != T) {
    ancestor = ancestor._parent;
  }
  return ancestor?.component as T?;
}