applyValueChanging method

FdcFieldValueChangeResult<T>? applyValueChanging({
  1. required FdcDataSet dataSet,
  2. required FdcGridRowContext row,
  3. required int rowIndex,
  4. required int columnIndex,
  5. required String fieldName,
  6. required Object? oldValue,
  7. required Object? newValue,
})

Invokes onValueChanging using this column's concrete generic value type.

Grid state code often stores columns through erased/dynamic references, but the interceptor callback is typed as FdcColumnValueChangingContext<T>. Keeping the invocation on the column preserves the concrete T and avoids runtime function-type mismatches such as passing FdcColumnValueChangingContext<dynamic> to a String interceptor.

Implementation

FdcFieldValueChangeResult<T>? applyValueChanging({
  required FdcDataSet dataSet,
  required FdcGridRowContext row,
  required int rowIndex,
  required int columnIndex,
  required String fieldName,
  required Object? oldValue,
  required Object? newValue,
}) {
  final callback = onValueChanging;
  if (callback == null) {
    return null;
  }

  final context = FdcColumnValueChangingContext<T>(
    dataSet: dataSet,
    column: this,
    row: row,
    rowIndex: rowIndex,
    columnIndex: columnIndex,
    fieldName: fieldName,
    oldValue: oldValue as T?,
    newValue: newValue as T?,
  );
  final result = callback(context) ?? context.accept();
  return result.withAdditionalValues(context.additionalValueSnapshot);
}