getRowDetails method
Returns the details of the row at the given rowIndex
.
The returned DataGridRowDetails object contains:
- DataGridRowDetails.dataGridRow: The data associated with the row, or
null
if the row is not a default row. - DataGridRowDetails.isSelected: Indicates whether the row is currently selected.
- DataGridRowDetails.rowType: Specifies the type of the row.
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,
);
}