apply<T extends DataGridRow> method

  1. @override
DataGridState<T>? apply<T extends DataGridRow>(
  1. EventContext<T> context
)
override

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 row = context.state.rowsById[rowId];
  if (row == null) {
    return null;
  }

  final column = context.state.columns.firstWhere((c) => c.id == columnId);
  if (column.cellValueSetter != null) {
    column.cellValueSetter!(row, value);
  }

  final newRowsById = Map<double, T>.of(context.state.rowsById);
  context.dataIndexer.setData(newRowsById);

  return context.state.copyWith(rowsById: newRowsById);
}