clearElementChildren function

void clearElementChildren(
  1. HTMLElement container
)

Removes all child nodes from the given container element.

This function iterates over all children of the container and removes them until no child remains.

Example:

clearElementChildren(myDiv);

Implementation

void clearElementChildren(web.HTMLElement container) {
  while (container.firstChild != null) {
    container.removeChild(container.firstChild!);
  }
}