Repository navigation
Conversation
…ults
ruflet_core gives several controls default values in shapes the parsers
did not read:
- alignment "center" (FilledIconButton, FilledTonalIconButton,
OutlinedIconButton, the cupertino_* buttons, TimerPicker): parseAlignment
indexed the String like a map and threw, so the control built with
default arguments showed Flutter's error widget.
- padding {"all": 8} (the icon buttons) and {"all": 7}
(cupertino_text_field), border_radius {"all": 8.0} (the cupertino_*
buttons): read as zero, so IconButton lost its padding, CupertinoButton
its default radius of 8 and CupertinoTextField its default padding of 7.
Every published gem sends these values, so the renderer has to read them:
- parseAlignment also reads the nine named alignments (top_left ...
bottom_right), folded like parseEnum; an unknown name gives the default.
- parseEdgeInsets, parseEdgeInsetsDirectional and parseBorderRadius read
"all" as the value of every side/corner the map does not name.
Numbers, {x, y} maps and side/corner maps without "all" parse as before.
Fixes #118
…ment-and-all-shapes
Before #118's alignment fix, page.window.alignment = "center" threw while the Window service read its props, so the title, size and position were all dropped. The test fails that way with alignment.dart reverted (+4 -6) and checks the named values give the same window update as their {x, y} maps.
ruby_default_shapes_test.dart covers it on both designs; the check reports it as covered now.
…ment-and-all-shapes
…ment-and-all-shapes
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #118
What changed
ruflet_coregives some controls default values in shapes the parsers did not read. Every published gem (0.0.13 to 0.0.23) sends them. The renderer now reads them:parseAlignment(utils/alignment.dart) also reads the nine named alignments:top_left,top_center,top_right,center_left,center,center_right,bottom_left,bottom_center,bottom_right. Names are folded likeparseEnum, sotopLeftandTOP_LEFTalso work. An unknown name gives the caller's default._TypeError: type 'String' is not a subtype of type 'int' of 'index'. Flutter then showed its error widget in place ofFilledIconButton,FilledTonalIconButtonandOutlinedIconButton(both designs),Button/FilledButton/FilledTonalButtonfromcupertino_*_button(both designs), andTimerPicker(iOS). On desktop, theWindowservice threw the same error while reading its props, and its catch only logs it.parseEdgeInsets,parseEdgeInsetsDirectionalandparseBorderRadiusread an"all"key as the value for every side or corner the map does not name. Before,{"all": 8}parsed toEdgeInsets.zeroand{"all": 8.0}toBorderRadius.zero.Unchanged: numbers,
{x, y}maps, side maps and corner maps without"all", andnull. The new tests assert each of these.Tests only:
TimerPickeris dropped from the coverage check'sknownGaps, because the new test covers it on both designs and the check reported it as "covered now".The fix is in the engine because the published gems cannot be changed. The Ruby defaults are fixed separately in AdamMusa/ruflet#100, so new gems also render on today's template. This reaches published gems only through a ruflet-template engine sync (D1: prepared, merged by the owner). Template PR #2 syncs f44e7df and does not include this change.
How verified
Final head a7ba175 (base 1da4885 merged in), flutter 3.41.2. The PR diff against the base is the same as at e762730.
flutter testinpackages/ruflet+2336, all pass;packages/ruflet_charts(readsparseBorderRadius/parseEdgeInsets) analyze clean, +90, all pass.knownGapsline inpackages/rufletandpackages/ruflet_lottieonly. On a7ba175:test/contractplus both new test files +45, all pass;flutter analyzeon the 6 touched files: no issues;packages/ruflet_lottie(readsgetAlignment) analyze clean, +19, all pass.The new tests, and the author's earlier runs:
New
packages/ruflet/test/widgets/ruby_default_shapes_test.dart(28 tests). On both designs it mounts the exact wireto_patchgives forfilled_icon_button,filled_tonal_icon_button,outlined_icon_button,cupertino_button,cupertino_filled_button,cupertino_tinted_button,cupertino_timer_pickerandcupertino_text_fieldwith default arguments. That wire is the same on ruflet main a9b58473. It asserts:ErrorWidgetIconButton/CupertinoButtonpaddingEdgeInsets.all(8)and alignmentAlignment.centerCupertinoButton.borderRadiusBorderRadius.circular(8)CupertinoTimerPicker.alignmentAlignment.centerCupertinoTextField.paddingEdgeInsets.all(7)It also covers every named alignment, unknown names, and the shapes that parsed before.
New
packages/ruflet/test/widgets/window_named_alignment_test.dart(10 tests). On macOS and Windows it mountsPage{title, window{alignment, width: 500, height: 400}}(the wire Ruby sends foralignment: "center"), mocks thewindow_managerandscreen_retrieverchannels, and asserts the calls that reach the platform: the title, the size, the aligned position, then the title bar style."center","bottom_right"and"bottomRight"give the same calls as{x: 0, y: 0}and{x: 1, y: 1}.Bug planted back: with all three parser changes reverted,
ruby_default_shapes_test.dartfails +5 -23. The 5 that still pass are the "keeps the old meaning" tests and the android picker and text field, which never read these keys. Withalignment.dartreverted,window_named_alignment_test.dartfails +4 -6: no call at all reaches the platform for any of the 6 string cases. The 4 map cases still pass.flutter testinpackages/rufleton da00f29: +2336, all tests pass.On e762730:
test/contractand both new test files, +45, all pass.flutter analyzeon the 6 touched files: no issues.Ruby side (ruflet main a9b58473):
WindowControl.new(alignment: "center", width: 500, height: 400).to_patchgives{"_c":"Window","_i":2,"alignment":"center","width":500,"height":400}. The H1 goldens pass there (compat.rb --jobs 4: 290 goldens;compat_goldens_test.rb: 298 runs, 0 failures). This PR changes no Ruby code.Behavior changes
All bug fixes (D6). No app code change is needed for any of them.
alignment: "top_left"-style value an app passes. No input that rendered before changes.page.window.alignmentgiven as a named string (for example"center") made theWindowservice throw before it applied anything. The catch only logged it, so the window's title, size, position, opacity and every other window prop were silently dropped, in every window update (including a page title change) for as long as the alignment stayed a named string. Now all of them apply and the window moves to the named alignment, the same as the matching{x, y}value."all"padding is applied instead of dropped.filled_icon_button,filled_tonal_icon_buttonandoutlined_icon_buttonbuilt with an explicit alignment used to get 0 padding. They now get the 8 that Ruby's default intends (Flet's and Flutter's IconButton default).cupertino_text_fieldon iOS goes from 0 inner padding to 7. That is the engine's own declared default for this key andCupertinoTextField's Flutter default. This is the most visible change: every Cupertino text field built with default arguments gains its 7 px inset."all"radius is applied instead of dropped.cupertino_*_buttonon iOS with an explicit alignment went from square corners to radius 8. Radius 8 is the engine's own default when no radius is sent."all"plus some named sides or corners (for example{"all": 8, "left": 2}) used to give 0 for the unnamed sides. It now gives theallvalue for them.If the owner wants the crash fixes (1 and 2) shipped without the visual changes in 3 to 5, the
alignment.darthunk can be taken on its own. It is independent of theedge_insets.dartandborders.darthunks.