styleForCell method

Style? styleForCell({
  1. required int row,
  2. required int column,
  3. required TableThemeSection section,
  4. required int rowCount,
  5. required int columnCount,
  6. required bool hasHeader,
  7. required bool hasDarkBackground,
})

Returns a style when the effect applies to the target cell.

Implementation

Style? styleForCell({
  required int row,
  required int column,
  required TableThemeSection section,
  required int rowCount,
  required int columnCount,
  required bool hasHeader,
  required bool hasDarkBackground,
}) {
  if (!_matchesSection(section) || !_matchesCoordinates(row, column)) {
    return null;
  }
  if (style == null && gradient.isEmpty) return null;

  Style? result = style?.copy();
  if (gradient.isNotEmpty) {
    final sampled = _sampleGradientCellColor(
      row: row,
      column: column,
      rowCount: rowCount,
      columnCount: columnCount,
      hasHeader: hasHeader,
      axis: gradientAxis,
      hasDarkBackground: hasDarkBackground,
      gradientPalette: gradient,
    );
    if (sampled != null) {
      if (result == null) {
        result = Style();
        result.foreground(sampled);
      } else {
        final existing = result.foregroundColor;
        if (existing == null || blendMode == TableBlendMode.normal) {
          result.foreground(sampled);
        } else {
          result.foreground(
            TableTheme.applyBlendMode(
              existing,
              sampled,
              blendMode,
              hasDarkBackground: hasDarkBackground,
            ),
          );
        }
      }
    }
  }
  return result;
}