pathToPane method

List<MultiplePaneList>? pathToPane(
  1. String paneId, {
  2. bool removeGivenPane = false,
})

Uses DFS to search for the ancestor tree of a given pane ID. Set removeGivenPane if the SinglePaneList containing the paneId should be deleted. This is used by the removePaneById method.

Implementation

List<MultiplePaneList>? pathToPane(
  String paneId, {
  bool removeGivenPane = false,
}) {
  for (final val in value) {
    if (val is SinglePaneList) {
      if (val.paneId == paneId) {
        if (removeGivenPane) value.remove(val);
        return [this];
      }
    } else {
      final tmp = (val as MultiplePaneList)
          .pathToPane(paneId, removeGivenPane: removeGivenPane);
      if (tmp != null) return [this, ...tmp];
    }
  }
  return null;
}