selectRow method
Toggles, selects, or clears selection for row.
Implementation
void selectRow(TreeRow row, {bool? selected, bool shiftPressed = false}) {
if (!isRowSelectable(row)) {
return;
}
final id = row.sourceNode!.id!;
final current = Set<Object>.of(selectedRowIdsNotifier.value);
final next = switch (rowSelectionMode) {
TreeDataTableRowSelectionMode.none => current,
TreeDataTableRowSelectionMode.single => selected == false ? <Object>{} : <Object>{id},
TreeDataTableRowSelectionMode.multiple when selected != false && shiftPressed && _lastSelectionAnchorId != null =>
_selectionWithVisibleRange(current, _lastSelectionAnchorId!, id),
TreeDataTableRowSelectionMode.multiple =>
selected ?? !current.contains(id) ? (current..add(id)) : (current..remove(id)),
};
if (rowSelectionMode != TreeDataTableRowSelectionMode.none && selected != false) {
_lastSelectionAnchorId = id;
}
_applyUserSelection(next);
}