isInDOM function

bool isInDOM(
  1. dynamic element
)

Returns true if element is in DOM tree.

element Can be a Node or a List of Node.

Implementation

bool isInDOM(dynamic element) {
  if (element == null) return false;

  if (element is Node) {
    return document.body!.contains(element);
  } else if (element is List) {
    for (var elem in element) {
      var inDom = isInDOM(elem);
      if (inDom) return true;
    }
    return false;
  }

  return false;
}