findUIComponentByChild method

UIComponent? findUIComponentByChild(
  1. UIElement? child
)
inherited

Implementation

UIComponent? findUIComponentByChild(UIElement? child) {
  if (child == null) return null;
  if (identical(child, _content)) return this;

  for (var elem in _content!.children) {
    if (identical(child, elem)) {
      return this;
    }
  }

  if (_renderedElements != null && _renderedElements!.isNotEmpty) {
    for (var elem in _renderedElements!) {
      if (elem is UIComponent) {
        var uiComp = elem.findUIComponentByChild(child);
        if (uiComp != null) return uiComp;
      }
    }
  }

  var subUIComponents = this.subUIComponents;

  for (var elem in subUIComponents) {
    var uiComp = elem.findUIComponentByChild(child);
    if (uiComp != null) return uiComp;
  }

  var deepChild = findInContentChildDeep((elem) => identical(child, elem));
  if (deepChild != null) return this;

  return null;
}