1

when I build flutter to web platform with command --tree-shake-icons I get this error.

This application cannot tree shake icons fonts. It has non-constant instances of IconData at the following locations:

file:///Users/xxx/Documents/flutter/packages/flutter/lib/src/widgets/icon_data.dart:22:9

file:///Users/xxx/Documents/hxgy/flutter/projectName/lib/utils/font_util/font_utils.dart:13:7
Target web_-release_bundle failed: Exception: Avoid non-constant invocations of IconData or try to build again with
--no-tree-shake-icons.

I need flutter to automatically compress the size of the font ICONS because they are too big,so I did not use --no-tree-shake-icons commander.

ZeroJsus
  • 11
  • 4
  • You need first run flutter build apk and then copy compressed otf cp -r ./build/app/intermediates/flutter/release/flutter_assets/ ./build/web/assets – ijj Nov 09 '22 at 18:22

1 Answers1

3

Flutter web doesn't support --tree-shake-icons yet. This could help.