Skip to content

feat: add Table control - #33

Merged
AdamMusa merged 2 commits into
codex/engine-initializationfrom
feat/table
Oct 29, 2026
Merged

AdamMusa merged 2 commits into
codex/engine-initializationfrom
feat/table

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Adds Table and its TableRow child type (Work Package F, item F5). It is a plain grid for layouts such as receipts, spec sheets and key/value lists, where DataTable is too heavy.

Ruby counterpart: AdamMusa/ruflet#47

Rendering

lib/src/controls/table.dart is one design-neutral file that imports only widgets.dart. Material and Cupertino render the same thing: Flutter's Table inside LayoutControl.

  • Rows come from rows, or block children in controls when rows is empty. Hidden rows are skipped. A child that is not a TableRow renders an ErrorControl whose message points to table_row.
  • Short rows are padded with empty cells up to the longest row, because Flutter asserts equal cell counts. A hidden cell keeps its slot, so the cells after it stay in their column. When every row is empty, the table renders no rows instead of asserting.
  • Rows and cells are keyed by control id, so updates reuse elements.
  • TableRow is a child type only (R3), so it has no createWidget case.

Wire keys

Ruby keyword Flutter Default
rows / controls children (TableRows) []
column_widths columnWidths: { "0" => {type, value} } —
default_column_width defaultColumnWidth {type: "flex", value: 1}
border_color TableBorder sides; no border when nil nil
border_width side width 1.0
border_radius TableBorder.borderRadius 0
inner_borders horizontalInside/verticalInside true
default_vertical_alignment top/middle/bottom/baseline/fill/intrinsicHeight (snake_case OK; baseline sets textBaseline: alphabetic) top
cell_padding Padding around every cell nil
TableRow controls row cells
TableRow bgcolor TableRow.decoration: BoxDecoration(color:) nil

Column width types are flex (value = flex factor, default 1), fixed (pixels), fraction (0..1 of the table width) and intrinsic (optional flex). A bare number means a fixed width. Ruby hash keys arrive as strings and are parsed with int.tryParse, so integer keys also work.

Events: only the common on_animation_end and on_size_change.

Tests

  • New test/widgets/ruby_table_test.dart, 32 tests on iOS and Android. The table is 400 px wide unless noted.
    • Default columns share the width: each cell is 400/3, in row-major geometry, with no border.
    • A fixed column is exactly 80 px and flex 1:2 splits the remaining 320.
    • Fraction 0.25 gives 100, a bare number gives 50 and the default flex column takes the rest (250); intrinsic columns shrink to their content.
    • default_column_width fixed at 120 applies to unlisted columns.
    • Short rows are padded to [2, 2] and hidden rows are skipped.
    • A hidden cell keeps its column.
    • Row bgcolor becomes a BoxDecoration.
    • A border is drawn only with border_color; width, radius and inner_borders: false are checked.
    • cell_padding insets each cell: the content is 84 px inside a 100 px column, at offset (8, 8).
    • All five vertical alignments are passed through.
    • controls works as a fallback.
    • Empty tables and empty rows render, and non-row children give an ErrorControl.
  • New matrix fixture Table, two rows where the second has one cell, which proves the short-row padding on all 5 platforms.
  • verify_pr.sh with Flutter 3.41.2: +732: All tests passed! (baseline 695). flutter analyze lib test reports No issues found!. The wire-key audit shows 0 new findings: Table and TableRow have every key read.

Render Ruby table/table_row as a design-neutral Flutter Table: flex/fixed/fraction/intrinsic column widths, optional TableBorder, row bgcolor, cell padding and vertical alignment. Short rows are padded so Flutter's equal-cell assertion never fires, and hidden cells keep their column.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant