Skip to content

fix: parse extension enum names with the shared parseEnum - #76

Merged
AdamMusa merged 5 commits into
codex/engine-initializationfrom
fix/extension-enum-snake-case
Nov 2, 2026
Merged

AdamMusa merged 5 commits into
codex/engine-initializationfrom
fix/extension-enum-snake-case

Conversation

@AdamMusa

@AdamMusa AdamMusa commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Depends on #63. This branch is stacked on fix/parse-curve-snake-case and merges in the latest codex/engine-initialization. Until #63 merges, review only the commit "fix: parse extension enum names with the shared parseEnum".

What

Nine extension packages compared enum names inline:

X.values.firstWhereOrNull((e) => e.name.toLowerCase() == value.toLowerCase()) ?? defaultValue

Ruby snake_case names never matched, so these values silently fell back to the default:

  • space_between / space_evenly (charts)
  • not_visible_respect_margin, append_dot, set_north, bottom_left (map)
  • best_for_navigation, automotive_navigation (geolocator)
  • aac_lc, voice_recognition, mix_with_others (audio_recorder)
  • first_unlock_this_device (secure_storage)

All 22 comparisons now call the shared parseEnum from #63. It matches case-insensitively with underscores removed on both sides, so exact and camelCase names keep working. That includes the enum names that contain underscores in Dart, like flutter_secure_storage's RSA_ECB_PKCS1Padding. The now-unused package:collection imports are removed.

Package Parsers
ruflet_ads parseTemplateType, parseNativeTemplateFontStyle
ruflet_audio parseReleaseMode
ruflet_audio_recorder parseAudioEncoder, parseAndroidAudioSource, parseIosAudioCategoryOption
ruflet_charts parseTooltipDirection, parseBarChartAlignment, parseFLHorizontalAlignment, parseRadarShape
ruflet_datatable2 parseColumnSize
ruflet_geolocator parseLocationAccuracy, parseActivityType
ruflet_map parseAttributionAlignment, parsePatternFit, parseCursorRotationBehaviour, parseEvictErrorTileStrategy
ruflet_secure_storage parseKeychainAccessibility, parseKeyCipherAlgorithm, parseStorageCipherAlgorithm, parseAccessControlFlag
ruflet_video parsePlaylistMode

Bug fixed along the way (ads): parseTemplateType and parseNativeTemplateFontStyle compared against e.toString() ("templatetype.small"), not e.name. Ruby's native_ad(template_style: { template_type: "small" }) therefore always rendered the medium template, and the text-style style was always ignored. Both now match the plain names Ruby sends.

How it was verified

  • Packages with a test/ dir (ads, charts, datatable2, map, video): each gets a new test/enum_name_parsing_test.dart (2 tests each). The tests cover camelCase, snake_case and upper-case names; unknown and null names keeping the default; and, for ads, template_type: "small" through parseNativeTemplateStyle.

  • Packages without a test/ dir (audio, audio_recorder, geolocator, secure_storage): flutter pub get + flutter analyze. Each change is the same one-line substitution into parseEnum, whose behavior fix: accept snake_case curve and enum names from Ruby #63 tests in core. I also checked every enum's value names in the pinned dependency sources:

    • AudioEncoder.aacLc…, AndroidAudioSource.voiceRecognition…, IosAudioCategoryOption.mixWithOthers…
    • LocationAccuracy.bestForNavigation…, ActivityType.automotiveNavigation…
    • KeychainAccessibility.first_unlock_this_device…, KeyCipherAlgorithm.RSA_ECB_PKCS1Padding…, StorageCipherAlgorithm.AES_GCM_NoPadding…, AccessControlFlag.devicePasscode…
    • ReleaseMode.release/loop/stop

    No two values collide once underscores are removed and case is ignored.

team/verify_pr.sh <engine> "" with EXT_PKGS set to all nine touched packages, at head 9695276 (latest base b4d3f8e merged in):

  • PASS: core flutter test +743 (base + fix: accept snake_case curve and enum names from Ruby #63's 9) and flutter analyze lib test clean.
  • Tests: ads +3, charts +4, datatable2 +7, map +4, video +5, all passed. audio, audio_recorder, geolocator and secure_storage have no test/ dir (SKIP).
  • Analyze: clean for ads, audio, datatable2, geolocator, map, secure_storage and video.
  • FAIL lines are pre-existing on the base (same messages there) and are not on lines this PR touches:
    • ruflet_audio_recorder (1): manageAudioSession is deprecated (parseIosRecordConfig). Replacing it with AudioRecorder.ios.manageAudioSession is an API migration with behavior impact, so I left it out of this PR.
    • ruflet_charts (3): two unnecessary_const in charts.dart:15,25, and provider imported by the existing cupertino_charts_test.dart without a dev_dependency.
    • These are left for a separate cleanup, like chore/color-pickers-analyzer (chore: clear ruflet_color_pickers analyzer issues #75).

Verify is clean once chore/extension-analyzer-cleanup (#77) merges.

Nine extension packages compared enum names inline with
e.name.toLowerCase() == value.toLowerCase(), so Ruby snake_case names
such as space_between, not_visible_respect_margin or
best_for_navigation silently fell back to the default. They now call
the core parseEnum, which matches case-insensitively with underscores
removed.

This also fixes the ads template_type and font style parsers, which
compared against the enum's toString() ("TemplateType.small") and so
never matched the plain names Ruby sends.
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.

2 participants