findParentNode static method

ElectricalNode? findParentNode(
  1. ElectricalNode? root,
  2. String childId
)

Find parent of a node

Implementation

static ElectricalNode? findParentNode(
  ElectricalNode? root,
  String childId,
) {
  if (root == null) return null;

  return root.map(
    source: (node) => _findParentInChildren(node, node.children, childId),
    protection: (node) => _findParentInChildren(node, node.children, childId),
    panel: (node) => _findParentInChildren(node, node.children, childId),
    load: (_) => null,
  );
}