Skip to content

feat: add FittedBox control - #31

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

AdamMusa merged 2 commits into
codex/engine-initializationfrom
feat/fitted-box

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Adds the FittedBox control (Work Package F, item F4). It scales and positions its content inside the box Ruby gives it, for example a price that must fit a fixed slot.

Ruby counterpart: AdamMusa/ruflet#46

Rendering

lib/src/controls/fitted_box.dart is one design-neutral file that imports only widgets.dart. Material and Cupertino render the same thing: Flutter's FittedBox inside LayoutControl, which applies width, height, expand, margin and the other common keywords.

Wire keys

Ruby keyword Flutter Default
content child none; renders an empty box (like RotatedBox, so a hidden child does not error)
fit fit (BoxFit; scaleDown or scale_down) contain
alignment alignment Alignment.center
clip_behavior clipBehavior none
common layout keywords LayoutControl

Events: only the common on_animation_end and on_size_change.

Tests

  • New test/widgets/ruby_fitted_box_test.dart, 20 tests on iOS and Android. A 100x40 fitted_box around a 400x40 child checks the painted rectangle, mapped through the FittedBox transform, for each fit:
    • scaleDown: (0, 15, 100, 10), with the default alignment and clip checked;
    • scale_down on a small 50x20 child: left unscaled at (25, 10);
    • default contain: scales a 50x10 child up to 100x20;
    • fill, cover, fitWidth, fit_height and none each paint their expected rectangle;
    • alignment bottom-left with clip_behavior: hard_edge paints at (0, 30, 100, 10);
    • with no content, the box renders empty at its Ruby size.
  • The default matrix fixture covers it on all 5 platforms.
  • verify_pr.sh with Flutter 3.41.2: +720: All tests passed! (baseline 695). flutter analyze lib test reports No issues found!. The wire-key audit shows 0 new findings, and FittedBox has every key read.

Render Ruby fitted_box as a design-neutral FittedBox: fit (BoxFit, default contain; camelCase or snake_case), alignment and clip_behavior, wrapped in LayoutControl.
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