withAddNode<T> method Null safety

TreeViewController withAddNode<T>(
  1. String key,
  2. Node<T> newNode,
  3. {Node? parent,
  4. int? index,
  5. InsertMode mode = InsertMode.append}

Adds a new node to an existing node identified by specified key. It returns a new controller with the new node added. This method expects the user to properly place this call so that the state is updated.

See TreeViewController.addNode for info on optional parameters.

  controller = controller.withAddNode(key, newNode);


TreeViewController withAddNode<T>(
  String key,
  Node<T> newNode, {
  Node? parent,
  int? index,
  InsertMode mode: InsertMode.append,
}) {
  List<Node> _data =
      addNode<T>(key, newNode, parent: parent, mode: mode, index: index);
  return TreeViewController(
    children: _data,
    selectedKey: this.selectedKey,