focusOut method

void focusOut()

← key: collapse an expanded folder, else step out to the parent.

Implementation

void focusOut() {
  final id = focused;
  if (id == null) return;
  final n = node(id);
  if (n != null && n.isFolder && n.hasChildren && _expanded.contains(id)) {
    _expanded.remove(id);
    notifyListeners();
    return;
  }
  final ancestors = TreeOps.ancestorsOf<T>(_roots, id);
  if (ancestors.isNotEmpty) {
    _focused = ancestors.last;
    notifyListeners();
  }
}