headingRowColor property Null safety

MaterialStateProperty<Color?>? headingRowColor
final

The background color for the heading row.

The effective background color can be made to depend on the MaterialState state, i.e. if the row is pressed, hovered, focused when sorted. The color is painted as an overlay to the row. To make sure that the row's InkWell is visible (when pressed, hovered and focused), it is recommended to use a translucent color.

DataTable(
  headingRowColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
    if (states.contains(MaterialState.hovered))
      return Theme.of(context).colorScheme.primary.withOpacity(0.08);
    return null;  // Use the default value.
  }),
)

See also:

Implementation

final MaterialStateProperty<Color?>? headingRowColor;