Skip to content

fix: resolve non-constant IconData preventing icon font tree-shaking#427

Open
ps9310 wants to merge 1 commit intoZebraDevs:mainfrom
ps9310:fix/icon-tree-shaking-v2
Open

fix: resolve non-constant IconData preventing icon font tree-shaking#427
ps9310 wants to merge 1 commit intoZebraDevs:mainfrom
ps9310:fix/icon-tree-shaking-v2

Conversation

@ps9310
Copy link
Copy Markdown
Contributor

@ps9310 ps9310 commented Mar 27, 2026

Summary

  • Replace _copyWith() in IconExtensions.apply() with a lookup into const iconsRound/iconsSharp maps, eliminating non-constant IconData construction that broke --tree-shake-icons
  • Add iconsRound and iconsSharp codePoint lookup maps to zeta_icons (will be auto-generated by the zeta-icons template going forward)
  • Replace non-constant IconData in example app with ZetaIcon widget
  • Bump zeta_icons 1.9.2 → 1.9.3, zeta_flutter 1.4.4 → 1.4.5

Fixes the Flutter web release build error:

This application cannot tree shake icons fonts. It has non-constant instances of IconData

Depends on

Test plan

  • All 12 icon tests pass
  • flutter build web --release --tree-shake-icons succeeds
  • Icon fonts are tree-shaken (MaterialIcons 99.4%, zeta-icons-sharp 18.7%, zeta-icons-round 14.9%)
  • flutter analyze passes with no issues

Add iconsRound and iconsSharp codePoint lookup maps to zeta_icons so
that IconExtensions.apply() returns pre-existing const IconData values
instead of constructing new ones at runtime. This allows Flutter to
tree-shake unused icon fonts on web builds.

The lookup maps will be auto-generated by the zeta-icons repo template
going forward. Also replace non-constant IconData usage in the example
app with ZetaIcon widget.
@ps9310 ps9310 requested a review from a team as a code owner March 27, 2026 11:00
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