searchAllTreesWithTitleDFS<T extends AbsNodeType> function

void searchAllTreesWithTitleDFS<T extends AbsNodeType>(
  1. TreeType<T> tree,
  2. String text,
  3. List<TreeType<T>> result
)

Using DFS to return all the trees if each of root's data contains searching text

Implementation

void searchAllTreesWithTitleDFS<T extends AbsNodeType>(
    TreeType<T> tree, String text, List<TreeType<T>> result) {
  if (tree.data.isUnavailable) return;

  if (tree.data.title.contains(text)) result.add(tree);

  for (var child in tree.children) {
    searchAllTreesWithTitleDFS(child, text, result);
  }
}