Reputation: 511666
I noticed that a Flutter Web project that I am making with the font_awesome_flutter plugin is being slowed down by the font_size download. I'm only using one icon from the font. Is there any way I can get this smaller?
Here is the data from webpagetest.org:
Upvotes: 0
Views: 1118
Reputation: 511666
Remove the font_awesome_flutter plugin from pubspec.yaml and wherever you are using it in your project.
You can just extract the icons you need from the font and discard the rest. An east way to do this is to use the IcoMoon site. For example I used the site to generate a font with only the Apple logo icon.
Note the code (eabe
). You'll use it later.
You get get instructions for doing that here. I called my font family Apple
.
To use your icon just use a Text widget with the code as the text and specify the font family that you registered in step 2.
FlatButton(
child: Text(
'\ueabe',
style: TextStyle(fontFamily: 'Apple', fontSize: 24),
),
onPressed: () {
model.onApplePressed();
},
),
Here is what it looks like in the app:
Rebuild your Flutter web app and put it online.
Here is retesting the site at webpagetest.org.
It's not as small as I expected but the font size is definitely better. (The site is also using Material Design icons so that may be contributing to the remaining font size.)
Upvotes: 1