Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude material fonts from flutter web release

I'm currently developing a flutter web application. I notice that the application takes a lot of time to load (an average of 20 seconds).

Here is a picture of what is taking so long.

The fetch of the 'FontManifest.json' and the fonts 'MaterialIcons-Regular.otf' and 'CupertinoIcons.tff' takes an average of 10 seconds. I'm not using any of these fonts, as I installed google fonts. It's just wasting time and data.

My question is: how can I get rid of these two fonts in flutter web or how can I reduce the time of waiting tffb + content downloading?

  • I tried to edit the 'FontManifest.json' and remove the '.otf' and '.tff' but as the files are auto generated, flutter rewrite them during each build.

  • I don't want to set use-material-design to false because i need some other features.

  • I already tried to edit the 'fonts' field of the 'pubspec.yaml' file, it doesn't work.

  • I have already read a few posts, but the questions mostly concerns display problems.

Thanks in advance for your help!

like image 446
Drewena Avatar asked Aug 10 '26 10:08

Drewena


1 Answers

There is a way instead to possibly optimize the build time of the other packages by using the command

cp -r ./build/app/intermediates/flutter/release/flutter_assets/ ./build/web/assets

and the treeshake function available by flutter

--tree-shake-icons

you can read more here

like image 58
anonymous Avatar answered Aug 13 '26 15:08

anonymous



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!