updateTreeWithSearchingTitle<T extends AbsNodeType> function
void
updateTreeWithSearchingTitle<T extends AbsNodeType>(})
Update field isShowedInSearching
of every node based on searching text.
Implementation
void updateTreeWithSearchingTitle<T extends AbsNodeType>(TreeType<T> tree, String searchingText,
{bool willBlurParent = false, bool willAllExpanded = false}) {
var root = findRoot(tree);
// searching text is empty -> mark all nodes displayable
if (searchingText.isEmpty) {
_updateFullTrueIsShowedInSearching<T>(root);
_updateFullBlurredValue<T>(root, false);
_updateFullExpanded<T>(root, false);
return;
}
//? Step 1: Mark entire tree to non-displayable
_updateFullFalseIsShowedInSearching<T>(root);
//? Optional: Blur all nodes
if (willBlurParent) {
_updateFullBlurredValue<T>(root, true);
}
//? Optional: Expand all nodes when perform search
if (willAllExpanded) {
_updateFullExpanded<T>(root, true);
}
//? Step 2: Find all nodes that contains searching text
List<TreeType<T>> foundNodes = [];
searchAllTreesWithTitleDFS<T>(root, searchingText, foundNodes);
//? Step 3: Update all branches from founded nodes to root as displayable
for (var node in foundNodes) {
node.data.isBlurred = false;
_updateAncestorsToDisplayable<T>(node);
}
}