collapseAll method
void
collapseAll()
Collapse all tree rows
Implementation
void collapseAll() {
if (!_state.isTreeData) return;
final flattenedRegularRows = _treeManager.flattenTree(
rows: _state.regularRows,
expandedIds: {},
);
final newTreeRows = [
// Prepend total rows as leaf nodes
..._state.totalRows.asMap().entries.map((entry) {
return TreeRow(
data: entry.value,
depth: 0,
hasChildren: false,
id: '_total_${entry.key}',
);
}),
...flattenedRegularRows,
];
_state = _state.copyWith(
expandedRowIds: {},
treeRows: newTreeRows,
allExpanded: false,
loadedRowCount: newTreeRows.length, // Load all visible tree rows
);
notifyListeners();
}