expandAll method
void
expandAll()
Expand all tree rows
Implementation
void expandAll() {
if (!_state.isTreeData) return;
final allExpandableIds = _treeManager.getAllExpandableIds(_state.regularRows);
final flattenedRegularRows = _treeManager.flattenTree(
rows: _state.regularRows,
expandedIds: allExpandableIds,
);
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: allExpandableIds,
treeRows: newTreeRows,
allExpanded: true,
loadedRowCount: newTreeRows.length, // Load all visible tree rows
);
notifyListeners();
}