toggle method

bool toggle(
  1. String id
)

Toggles a branch. Returns whether expansion state changed.

Implementation

bool toggle(String id) {
  final item = _findItem(id);
  if (item == null || !item.hasChildren) return false;
  final selectedId = selectedItem?.id;
  if (_expandedIds.contains(id)) {
    _expandedIds.remove(id);
  } else {
    _expandedIds.add(id);
  }
  _restoreSelection(id, selectedId: selectedId);
  return true;
}