apply<T extends DataGridRow> method
Apply this event's transformation to the state. Returns the new state, or null if no state change should occur. Can return a Future for async operations.
Implementation
@override
DataGridState<T>? apply<T extends DataGridRow>(EventContext<T> context) {
if (context.state.selection.mode == SelectionMode.none) {
return null;
}
final focusedRowId = context.state.selection.focusedRowId;
if (focusedRowId == null) return null;
final currentIndex = context.state.displayOrder.indexOf(focusedRowId);
if (currentIndex <= 0) return null;
final newRowId = context.state.displayOrder[currentIndex - 1];
return context.state.copyWith(
selection: context.state.selection.copyWith(
focusedRowId: newRowId,
selectedRowIds: {newRowId},
),
);
}