deleteChildRecursive method

void deleteChildRecursive(
  1. GroupViewModel? viewParent,
  2. RenderViewModel? child,
  3. int childIndex
)

Implementation

void deleteChildRecursive(GroupViewModel? viewParent, RenderViewModel? child, int childIndex) {
  if (viewParent == null || child == null) {
    return;
  }
  var childName = child.name;

  var childViewController = _controllerRegistry.getViewController(childName);
  if (childViewController != null) {
    childViewController.onViewDestroy(child);
  }

  if (child is GroupViewModel) {
    for (var i = child.childCount - 1; i >= 0; i--) {
      var nextChild = child.getChildAt(i);
      if (nextChild != null) {
        deleteChildRecursive(child, nextChild, -1);
      }
    }
  }

  viewParent.removeViewModel(child);
}