insertAtIndex method

void insertAtIndex(
  1. int index,
  2. dynamic parent,
  3. NodeData newNode, {
  4. bool closeCanInsert = false,
})

Inserts a node at position index in parent. The index value must be non-negative and no greater than length.

Implementation

void insertAtIndex(int index, dynamic parent, NodeData newNode,
    {bool closeCanInsert = false}) {
  assert(index <= parent.children.length);
  if (!closeCanInsert) {
    if (parent != null && !isExpanded(parent)) {
      return;
    }
  }
  parent.children.insert(index, newNode);
  _insertItemAtIndex(index, parent, isIndex: true);

  notifyListeners();
}