insertAtFront method

void insertAtFront(
  1. NodeData? parent,
  2. NodeData newNode, {
  3. bool closeCanInsert = false,
})

Insert a node in the head parent The parent node newNode The node will be insert closeCanInsert Can insert when parent closed

Implementation

void insertAtFront(NodeData? parent, NodeData newNode,
    {bool closeCanInsert = false}) {
  if (!closeCanInsert) {
    if (parent != null && !isExpanded(parent)) {
      return;
    }
  }
  parent!.children.insert(0, newNode);
  _insertItemAtIndex(0, parent);
  notifyListeners();
}