Skip to content

fix: extract icon constants for Flutter web tree-shaking compatibility#38

Merged
anilcancakir merged 1 commit intomainfrom
fix/icon-tree-shaking
Apr 9, 2026
Merged

fix: extract icon constants for Flutter web tree-shaking compatibility#38
anilcancakir merged 1 commit intomainfrom
fix/icon-tree-shaking

Conversation

@anilcancakir
Copy link
Copy Markdown
Contributor

Summary

  • Extract all runtime-conditional Icons.* references into static const fields across 10 files for Flutter web tree-shaking compatibility
  • Converts ternary expressions and switch statements to use const fields/maps so const_finder can detect all icon glyphs
  • Fixes 11+ broken icon usages that forced consumer apps to use --no-tree-shake-icons (+1.6MB)

Closes #37

Test plan

  • flutter analyze --no-fatal-infos — zero issues
  • flutter test — 589 tests pass
  • No test modifications — pure refactor with no observable behavior change
  • Verify no Icons.* literals remain in ternary/switch expressions (only in static const declarations)

Copilot AI review requested due to automatic review settings April 9, 2026 12:32
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors runtime-conditional Icons.* usages into static const icon fields / const maps so Flutter web icon tree-shaking (const_finder) can reliably detect required glyphs, preventing missing icons in release web builds.

Changes:

  • Replaced ternary-based icon selections with static const icon fields (e.g., visibility toggles, expand/collapse icons, theme toggle).
  • Replaced switch-based icon selection with static const lookup maps + defaults for notification icon resolution.
  • Documented the fix under [Unreleased] in the changelog.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lib/src/ui/widgets/magic_starter_user_profile_dropdown.dart Extracts theme toggle icons into static const fields.
lib/src/ui/widgets/magic_starter_team_selector.dart Extracts expand/collapse icons into static const fields for conditional rendering.
lib/src/ui/widgets/magic_starter_password_confirm_dialog.dart Extracts password visibility icons into static const fields.
lib/src/ui/widgets/magic_starter_notification_dropdown.dart Replaces switch-based icon selection with a static const icon map + default.
lib/src/ui/views/profile/magic_starter_profile_settings_view.dart Extracts visibility + device-type icons into static const fields used in conditionals.
lib/src/ui/views/notifications/magic_starter_notifications_list_view.dart Replaces switch expression icon selection with a static const icon map + default.
lib/src/ui/views/notifications/magic_starter_notification_preferences_view.dart Replaces switch-based channel icon selection with a static const icon map + default; extracts locked icon.
lib/src/ui/views/auth/magic_starter_reset_password_view.dart Extracts password visibility icons into static const fields used in ternaries.
lib/src/ui/views/auth/magic_starter_register_view.dart Extracts password visibility icons into static const fields used in ternaries.
lib/src/ui/views/auth/magic_starter_login_view.dart Extracts password visibility icons into static const fields used in ternaries.
CHANGELOG.md Adds an [Unreleased] bug-fix entry for icon tree-shaking compatibility.

@sentry
Copy link
Copy Markdown

sentry bot commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../views/auth/magic_starter_reset_password_view.dart 0.00% 2 Missing ⚠️
...i/widgets/magic_starter_notification_dropdown.dart 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@anilcancakir anilcancakir merged commit 999fd3f into main Apr 9, 2026
6 checks passed
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.

Icon tree-shaking breaks 11 icons in release web builds

2 participants