insertChild method
Implementation
Element insertChild(int index, Element node) {
final children = this.children;
if (index >= children.length) {
return appendChild(node) as Element;
} else if (index == 0) {
var child0 = firstChild;
if (child0 == null) {
return appendChild(node) as Element;
} else {
return insertBefore(node, child0) as Element;
}
} else {
var child = children.item(index)!;
return insertBefore(node, child) as Element;
}
}