updateTreeSingleChoice<T extends AbsNodeType> function
The tree is single choice, not multiple choice. Only leaf can be chosen.
Implementation
void updateTreeSingleChoice<T extends AbsNodeType>(
TreeType<T> tree, bool chosenValue) {
/// if `chosenValue == true`, all of its ancestors ancestors must have value
/// `isChosen == null` (because we need to customize UI of each inner node if
/// one of its children is chosen), others have value `false`.
///
/// Otherwise, just update everything - every nodes value to `false`.
// uncheck all
var root = findRoot(tree);
uncheckALl(root);
// if chosen value is true, update all of its ancestors value to null
if (chosenValue) {
_updateAncestorsToNull(tree);
} else {}
// update current node value
tree.data.isChosen = chosenValue;
}