addViewModel method

void addViewModel(
  1. RenderViewModel child,
  2. int index
)

Implementation

void addViewModel(RenderViewModel child, int index) {
  var oldParent = child.parent;
  if (oldParent != null && oldParent is GroupViewModel) {
    oldParent.removeViewModel(child);
  }

  child.parent = this;
  if (index > childCount || index < 0) {
    _children.add(child);
  } else {
    _children.insert(index, child);
  }
  _childrenMap[child.id] = child;
}