buildTable function

Widget buildTable(
  1. BuildContext context,
  2. OpenUiNode node
)

Implementation

Widget buildTable(BuildContext context, OpenUiNode node) {
  final theme = node.theme;
  final style = theme.styleOf('Table');
  final tableTheme = style.foreground == null
      ? theme
      : theme.withInk(style.foreground!);
  final columns = node.props.list('columns').map(_label).toList();
  final rows = node.props.list('rows').whereType<List<Object?>>().toList();
  final numeric = [
    for (var c = 0; c < columns.length; c++) _isNumeric(rows, c),
  ];
  final body = iuiTableBodyStyle(tableTheme);
  return IuiTable(
    head: [
      for (final c in columns) Text(c, style: iuiTableHeadStyle(tableTheme)),
    ],
    numeric: numeric,
    rows: [
      for (final (r, row) in rows.indexed)
        [
          for (var c = 0; c < columns.length; c++)
            _cell(
              context,
              node,
              c < row.length ? row[c] : null,
              body,
              slot: 'r$r.c$c',
            ),
        ],
    ],
  );
}