Skip to main content
StacTable allows you to build the Flutter Table widget using JSON. To know more about the Table widget in Flutter, refer to the official documentation.

Properties

PropertyTypeDescription
columnWidthsMap<int, StacTableColumnWidth>Determines the column width on a column by column basis, if a particular column entry has null width defaultColumnWidth is used. See StacTableColumnWidth
defaultColumnWidthStacTableColumnWidthDetermines the default column width. Defaults to flexColumnWidth. See StacTableColumnWidth
textDirectionStacTextDirectionDetermines the direction in which the columns are ordered. Can be rtl or ltr. Defaults to rtl.
borderStacTableBorderDefines the border style for StacTable. See StacTableBorder.
defaultVerticalAlignmentStacTableCellVerticalAlignmentDefines the verticalAlignment for the cells that don’t specify a verticalAlignment. Can be top, middle, bottom, baseline, fill & intrinsicHeight Defaults to top.
textBaseLineStacTextBaselineDefines the text baseline to use when verticalAlignment is baseline. Can be alphabetic or ideographic. There is no default value.
childrenList<StacTableRow>Rows that will be populated in the table. See StacTableRow.

Example

StacTable(
  columnWidths: {
    1: StacFixedColumnWidth(value: 200),
  },
  defaultColumnWidth: StacFlexColumnWidth(value: 1),
  textDirection: StacTextDirection.ltr,
  defaultVerticalAlignment: StacTableCellVerticalAlignment.bottom,
  border: StacTableBorder(
    color: '#428AF5',
    width: 1.0,
    style: StacBorderStyle.solid,
    borderRadius: StacBorderRadius.all(16.0),
  ),
  children: [
    StacTableRow(
      children: [
        StacTableCell(
          child: StacContainer(
            color: '#40000000',
            height: 50.0,
            child: StacCenter(child: StacText(data: 'Header 1')),
          ),
        ),
        StacTableCell(
          child: StacContainer(
            color: '#40000000',
            height: 50.0,
            child: StacCenter(child: StacText(data: 'Header 2')),
          ),
        ),
        StacTableCell(
          child: StacContainer(
            color: '#40000000',
            height: 50.0,
            child: StacCenter(child: StacText(data: 'Header 3')),
          ),
        ),
      ],
    ),
    StacTableRow(
      children: [
        StacTableCell(
          child: StacSizedBox(
            height: 50.0,
            child: StacCenter(child: StacText(data: 'Row 1, Cell 1')),
          ),
        ),
        StacTableCell(
          child: StacSizedBox(
            height: 50.0,
            child: StacCenter(child: StacText(data: 'Row 1, Cell 2')),
          ),
        ),
        StacTableCell(
          child: StacSizedBox(
            height: 50.0,
            child: StacCenter(child: StacText(data: 'Row 1, Cell 3')),
          ),
        ),
      ],
    ),
  ],
)