getRowDetails method

DataGridRowDetails? getRowDetails(
  1. int rowIndex
)

Returns the details of the row at the given rowIndex.

The returned DataGridRowDetails object contains:

Returns null if the rowIndex is not within the valid range of the data grid.

Implementation

DataGridRowDetails? getRowDetails(int rowIndex) {
  if (_dataGridStateDetails == null) {
    return null;
  }

  final DataGridConfiguration dataGridConfiguration =
      _dataGridStateDetails!();
  final RowType? rowType = _getRowType(dataGridConfiguration, rowIndex);

  if (rowType == null) {
    return null;
  }

  if (rowType != RowType.dataRow) {
    return DataGridRowDetails(
      rowType: rowType,
      dataGridRow: null,
      isSelected: false,
    );
  }

  final int recordIndex = grid_helper.resolveToRecordIndex(
    dataGridConfiguration,
    rowIndex,
  );

  final DataGridRow? dataGridRow =
      (recordIndex >= 0)
          ? grid_helper.getDataRow(dataGridConfiguration, recordIndex)
          : null;

  final bool isSelected =
      dataGridRow != null &&
      selection_manager.isSelectedRow(dataGridConfiguration, dataGridRow);

  return DataGridRowDetails(
    rowType: rowType,
    dataGridRow: dataGridRow,
    isSelected: isSelected,
  );
}