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 notify = context.notifyCellValueChanged;
  if (notify == null) return null;

  final rows = rowIds.isEmpty ? context.state.rowsById.keys : rowIds;
  final columns =
      columnIds ?? context.state.columns.map((c) => c.id).toList();

  for (final rowId in rows) {
    for (final columnId in columns) {
      notify(
        CellValueChange(
          rowId: rowId,
          columnId: columnId,
          value: null,
          source: CellValueChangeSource.refresh,
        ),
      );
    }
  }

  // Deliberately no state change: this event exists precisely so a render
  // refresh doesn't have to cost a state emission.
  return null;
}