withUpdateNode<T> method Null safety

TreeViewController withUpdateNode<T>(
  1. String key,
  2. Node<T> newNode,
  3. {Node? parent}

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

See TreeViewController.updateNode for info on optional parameters.

  controller = controller.withUpdateNode(key, newNode);


TreeViewController withUpdateNode<T>(String key, Node<T> newNode, {Node? parent}) {
  List<Node> _data = updateNode<T>(key, newNode, parent: parent);
  return TreeViewController(
    children: _data,
    selectedKey: this.selectedKey,