consumeSpanPadding property

bool consumeSpanPadding
final

Whether or not the decoration should extend to fill the space created by the SpanPadding.

Defaults to true, meaning if a Span is a row, the decoration will apply to the full SpanExtent, including the SpanPadding.leading and SpanPadding.trailing for the row. This same row decoration will consume any padding from the column spans so as to decorate the row as one continuous span.

{@tool snippet} This example illustrates how consumeSpanPadding affects SpanDecoration.color. By default, the color of the decoration consumes the padding, coloring the row fully by including the padding around the row. When consumeSpanPadding is false, the padded area of the row is not decorated.

TableView.builder(
  rowCount: 4,
  columnCount: 4,
  columnBuilder: (int index) => TableSpan(
    extent: const FixedTableSpanExtent(150.0),
    padding: const TableSpanPadding(trailing: 10),
  ),
  rowBuilder: (int index) => TableSpan(
    extent: const FixedTableSpanExtent(150.0),
    padding: TableSpanPadding(leading: 10, trailing: 10),
    backgroundDecoration: TableSpanDecoration(
      color: index.isOdd ? Colors.blue : Colors.green,
      // The background color will not be applied to the padded area.
      consumeSpanPadding: false,
    ),
  ),
  cellBuilder: (_, TableVicinity vicinity) {
    return Container(
      height: 150,
      width: 150,
      child: const Center(child: FlutterLogo()),
    );
  },
);

{@end-tool}

Implementation

final bool consumeSpanPadding;