Skip to content

fix: accept snake_case curve and enum names from Ruby - #63

Merged
AdamMusa merged 1 commit into
codex/engine-initializationfrom
fix/parse-curve-snake-case
Nov 2, 2026
Merged

AdamMusa merged 1 commit into
codex/engine-initializationfrom
fix/parse-curve-snake-case

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

What

Ruby-style snake_case names now reach the renderer. Before this PR they were silently dropped.

  • parseCurve (utils/animations.dart) lowercased the name but kept underscores. So "ease_in_out" fell back to the default curve without any message. For scroll_to and TabBar move_to the default is ease, for PageView it is the control's animation_curve, and for animation maps it is linear.
    • "linear" was also missing from the table. It is the Ruby animated_switcher default for switch_in_curve / switch_out_curve, and scroll_to(curve: "linear") animated with ease.
    • Unknown non-null names now print Warning: unknown curve "<name>"; using the default. before falling back.
  • parseEnum (utils/enums.dart), used by 62 call sites in core and 16 in extensions, had the same gap: it compared case-insensitively but kept underscores. SPEC R4 worked around this by asking every new parser to replaceAll("_", "") itself. Matching now goes through a new normalizeEnumName (lowercase, underscores removed) on both sides. "space_between", "spaceBetween" and "SPACE_BETWEEN" all match MainAxisAlignment.spaceBetween. Exact and case-insensitive matches behave as before.
  • Hand-written name tables in core utils had the same gap. All their keys are underscore-free lowercase, so they now look up normalizeEnumName(value):
    • keyboard type (parseTextInputType)
    • mouse cursor (parseMouseCursor)
    • autofill hint and context action
    • visual density and page transitions builder (theme.dart)
    • markdown extension set
    • FAB location

Single-word name matches (PointMode, TargetPlatform, AnimatedSwitcher transition) have no multi-word names and are left unchanged.

Not in this PR (same gap, separate packages)

These extension packages compare enum names inline with e.name.toLowerCase() == value.toLowerCase() instead of using the core parseEnum. Each line can become parseEnum(X.values, value, default), which now normalizes. I left them out to keep this core fix small; they are a follow-up.

  • ruflet_ads/lib/utils/native.dart:8,16
  • ruflet_audio/lib/src/utils/audio.dart:7
  • ruflet_audio_recorder/lib/src/utils/audio_recorder.dart:8,21,40
  • ruflet_charts/lib/src/utils/bar_chart.dart:57,239, charts.dart:209, radar_chart.dart:12
  • ruflet_datatable2/lib/src/utils/datatable.dart:9
  • ruflet_geolocator/lib/src/utils/geolocator.dart:10,34
  • ruflet_map/lib/src/utils/attribution_alignment.dart:8, map.dart:31,172,210
  • ruflet_secure_storage/lib/src/utils/secure_storage.dart:90,97,104,111
  • ruflet_video/lib/src/utils/video.dart:133

ruflet_map's curves already go through the core parseCurve, so they are fixed here.

Tests

New test/utils/enum_name_parsing_test.dart (9 tests):

  • parseCurve:
    • camelCase, snake_case, upper-case and lowercase names (easeInOut, ease_in_out, EASE_IN_OUT, easeinout, fast_out_slow_in, ease_in_out_cubic_emphasized, …)
    • linear resolves
    • null returns the default without a warning
    • unknown names (wobbly, ease_wobble) return the default or null and print exactly one warning, captured via debugPrint
    • parseAnimation and parseAnimationStyle read snake_case curve and reverse_curve
  • parseEnum:
    • camelCase, snake_case and upper-case names for MainAxisAlignment, Clip.antiAliasWithSaveLayer and ScrollViewKeyboardDismissBehavior.onDrag
    • unknown and null names keep the default
  • Name tables: street_address, all_scroll, telephone_number_national, adaptive_platform_density, fade_upwards, github_flavored and center_docked resolve, and misspelled names still fall back.
  • Widget: a Ruby AnimatedSwitcher with switch_in_curve: "ease_out_back" and switch_out_curve: "fast_out_slow_in" builds AnimatedSwitcher with those curves.

team/verify_pr.sh <engine> "" with EXT_PKGS="ruflet_map ruflet_color_pickers ruflet_spinkit" (the extensions that call the core parsers):

  • core packages/ruflet flutter test (Flutter 3.41.2): +704, all passed (baseline 695 + 9 new). flutter analyze lib test: No issues found. These two steps are the default verify scope, and both pass.
  • ruflet_map, ruflet_spinkit: tests pass, analyze clean.
  • ruflet_color_pickers: tests pass (+7). Its analyze reports 126 issues, all already present on base c9b9d76 (same count there; deprecated Color.value / withOpacity and similar). They are unrelated to this change, which touches no file in that package. This is why the script's overall line says FAIL.

Engine-only change; no Ruby counterpart is needed. Ruby already sends these names.

parseCurve lowercased the name but kept underscores, so Ruby's
"ease_in_out" silently fell back to the default curve, and "linear"
(the Ruby AnimatedSwitcher default) was missing from the table. Unknown
curve names now print a warning before falling back.

parseEnum and the hand-written name tables in core utils (keyboard
types, mouse cursors, autofill hints and actions, visual density, page
transitions, markdown extension sets, FAB locations) had the same gap.
They now compare names through normalizeEnumName: case-insensitive with
underscores removed, so camelCase and snake_case both match.
@AdamMusa
AdamMusa merged commit 0662d2b into codex/engine-initialization Nov 2, 2026
AdamMusa pushed a commit that referenced this pull request Nov 3, 2026
Review of #74 found two Material ContextMenu gaps. Both are already
closed in the merged code; this pins the one that had no test.

- An items-only menu (Ruby's ContextMenu sends `items` and the
  per-trigger lists, never `actions`): #78 made the Material renderer
  fall back to `items` before `actions` for every trigger and for a
  programmatic open, and ruby_material_context_menu_items_test.dart
  covers the right-click case.
- `primary_trigger: "long_press"`: parseContextMenuTrigger goes through
  the shared parseEnum, which #63 made compare names without case or
  underscores, so Material accepts Ruby's spelling as iOS does. Nothing
  tested it on Material.

ruby_context_menu_trigger_items_test.dart now long-presses a menu with
`primary_trigger` "long_press" and "longPress" on iOS and Android: each
shows `primary_items` (not `secondary_items`) and selecting reports
b: primary, tr: longPress. With parseEnum as it was before #63 the
Android "long_press" case fails (no menu opens). Context menu tests and
test/architecture: 317/317.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MqfxcsDiEUZngybe9L72JQ
AdamMusa pushed a commit that referenced this pull request Nov 3, 2026
Follow-up to #63 (snake_case curve names). parseCurve's table listed
every Flutter Curves constant except fastEaseInToSlowEaseOut, so
`curve: "fast_ease_in_to_slow_ease_out"` (or the camelCase name) printed
"unknown curve" and fell back to the default. It is in the table now.

enum_name_parsing_test.dart lists all 42 public Curves constants and
checks that each parses, by its snake_case and its Dart name, to that
very constant without a warning; this fails without the fix (the
warning for fast_ease_in_to_slow_ease_out). A second test reads the
Curves class from the Flutter SDK source this package resolves (via
.dart_tool/package_config.json) and requires the list to match it, so a
Flutter upgrade that adds a curve fails until parseCurve knows it.
test/architecture plus every test mentioning curves: 361/361.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MqfxcsDiEUZngybe9L72JQ
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