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) {
final cellId = '${rowId}_$columnId';
final current = context.state.selection.focusedCells;
if (current.isEmpty) {
// No anchor yet — treat like a plain focus
return context.state.copyWith(
selection: context.state.selection.copyWith(focusedCells: [cellId]),
);
}
if (current.last == cellId) return null; // already active, no-op
if (current.contains(cellId)) return null; // already in path, no-op
return context.state.copyWith(
selection: context.state.selection.copyWith(
focusedCells: [...current, cellId],
),
);
}