handleTap method

  1. @override
void handleTap(
  1. RowColumnIndex rowColumnIndex
)
override

Processes the selection operation when tap a cell.

Implementation

@override
void handleTap(RowColumnIndex rowColumnIndex) {
  final DataGridConfiguration dataGridConfiguration =
      _dataGridStateDetails!();
  _pressedRowColumnIndex = rowColumnIndex;
  if (dataGridConfiguration.selectionMode == SelectionMode.none) {
    return;
  }
  final int recordIndex = grid_helper.resolveToRecordIndex(
      dataGridConfiguration, rowColumnIndex.rowIndex);

  final RowColumnIndex previousRowColumnIndex = RowColumnIndex(
      dataGridConfiguration.currentCell.rowIndex,
      dataGridConfiguration.currentCell.columnIndex);
  if (!dataGridConfiguration.currentCell
      ._handlePointerOperation(dataGridConfiguration, rowColumnIndex)) {
    return;
  }
  final bool isShiftPressed = dataGridConfiguration.isShiftKeyPressed;
  // Issue:
  // Header checkbox selection causes shift selection to fail.
  //
  // Fix:
  // After header checkbox selection, the pressed rowIndex is set to -1.
  // To fix this, when performing shift or normal selection, if rowIndex is -1,
  // set it to the currently tapped rowIndex.
  if (_pressedRowIndex < 0 || !isShiftPressed) {
    _pressedRowIndex = recordIndex;
  }

  if (!isShiftPressed) {
    _shiftSelectedRows.clear();
    _processSelection(
        dataGridConfiguration, rowColumnIndex, previousRowColumnIndex);
  } else if (dataGridConfiguration.selectionMode == SelectionMode.multiple) {
    _processShiftKeySelection(rowColumnIndex, recordIndex);
  }
}