computeCellHeight method Null safety

  1. @protected
double computeCellHeight(
  1. GridColumn column,
  2. DataGridRow row,
  3. Object? cellValue,
  4. TextStyle textStyle

Calculates the height of the cell based on the DataGridCell.value. You can override this method to perform the custom calculation for hight.

If you want to calculate the width based on different TextStyle, you can override this method and call the super method with the required TextStyle. Set the custom ColumnSizer to SfDataGrid.columnSizer property.

class CustomColumnSizer extends ColumnSizer {
 double computeCellHeight(GridColumn column, DataGridRow row, Object cellValue,
     TextStyle textStyle) {
  TextStyle style = textStyle;
  if (column.columnName == 'Name')
   style = TextStyle(fontSize: 20, fontStyle: FontStyle.italic);
 return super.computeCellWidth(column, row, cellValue, style);

The auto size is calculated based on default TextStyle of the datagrid.


double computeCellHeight(GridColumn column, DataGridRow row,
    Object? cellValue, TextStyle textStyle) {
  final DataGridConfiguration dataGridConfiguration =
  final int rowIndex = grid_helper.resolveToRowIndex(dataGridConfiguration,
  return _measureCellHeight(column, rowIndex, cellValue, textStyle);