toggleNode<T> method Null safety

List<Node> toggleNode<T>(
  1. String key,
  2. {Node? parent}
)

Toggles an existing node identified by specified key. This method returns a new list with the specified node toggled.

Implementation

List<Node> toggleNode<T>(String key, {Node? parent}) {
  Node<T>? _node = getNode<T>(key, parent: parent);
  return updateNode<T>(key, _node!.copyWith(expanded: !_node.expanded));
}