findUIComponentByContent method

UIComponent? findUIComponentByContent(
  1. UIElement? content
)

Implementation

UIComponent? findUIComponentByContent(UIElement? content) {
  if (content == null) return null;
  if (identical(content, _content)) return this;

  if (_renderedElements == null || _renderedElements!.isEmpty) return null;

  for (var elem in _renderedElements!) {
    if (elem is UIComponent) {
      var uiComp = elem.findUIComponentByContent(content);
      if (uiComp != null) return uiComp;
    }
  }

  var subUIComponents = this.subUIComponents;

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

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

  return null;
}