isInDOM function
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;
}