Flutter Web FontAwesome fonts download size too big - flutter

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:

Remove the Font Awesome plugin from your project
Remove the font_awesome_flutter plugin from pubspec.yaml and wherever you are using it in your project.
Generate a font with only the icons that you need
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.
Add the font in Flutter
You get get instructions for doing that here. I called my font family Apple.
Use the icon in your app
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:
Check the size
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.)

Related

How can I control the Stoke ( thikness ) of the icons

when we put an Icon Like this
Icon(
Icons.notifications_outlined,
)
we can control the size and color... of that icon, but I want to control the Stroke width of the Icon (not the size of the icon, I want to control the width of the icon's line )
is it possible by any widget or any other way in flutter SDK?
please don't recommend packages of other icons
thanks
I didn't find any way from the flutter SDK to control the icons thinkers, I tried using CustomPainter, BoxShadow()...
alternatively, I used a different icons package which is the Ionicons, which belongs to the Ionic framework, I found out that there is a flutter package for those icons, see Ionicons
you can see a list of all icons here, https://ionic.io/ionicons
and they can be used like this:
Icon(Ionicons.add)
Icon(Ionicons.add_outline)
Icon(Ionicons.add_sharp)

Flutter: Use specific material icons without the whole MaterialIcons-Regular.otf

I am building a Flutter web app. I use a handful of material icons, but it brings the whole MaterialIcons-Regular.otf file with it. It is of 1.6 MB and takes time to load.
Is there a way to only bring the icons I need?
I can only think of using the icons as SVGs and bringing them separately with flutter_svg package.

Flutter Icon showing Icons that were different than specified

When I tell the icon to be on one type it shows something completely different.
Icon(
Icons.ac_unit
),
It was supposed to be an ac unit but it's this instead. This even affects included
widgets like the calendar widget.
Try flutter clean & flutter pub cache repair to see if it resolves your issue.

Flutter: Some of the material design icons are not supported

Seems like some of the material design icons are not supported. Like I want to use how_to_vote icon and it's actually listed in this page but it is not suppoted in Icons class. How can I use this and also why isn't it supported?
As of now, to use material design icons you have to add the package outline_material_icon in your pubspec.yaml. This will make available all the icons you want from this page
If you check the Icons class constants. There is no how_to_vote icon available. If you need to use that icon, download that from the material.io and add it to your app.

Can Google Flutter target iOS and Android in one app

In Ionic I can build one app and at runtime Ionic choose the right skin Cupertino or Android.
Can Flutter do the same? I have read the documentation but I can't see any wrappers around the Android and Cupertino widgets.
If you want to create separate iOs and Android "looks", you can use a plugin like this one:
https://pub.dartlang.org/packages/flutter_platform_widgets#-readme-tab-
You have full control over which parts of your UI should be platform-specific, and which parts you want to keep uniform. For example, you can create your own custom button instead of using Cupertino button on iOs and RaisedButton on Android, but you may want to use different TextField widgets on iOs and Android.
It does and it does not, some widgets behave differently out of the box depending on the platform. Like the ScrollView, which bounces on iOS and creates a wave like overlay on Android.
But for the real native experience you have to create your own widgets that build either Material or Cupertino UI.
Example:
...
Widget _customButton() {
return Platform.isIOS
? CupertinoButton(
child: Text('Tap me'),
onPressed: () {},
)
: RaisedButton(
child: Text('Tap me'),
onPressed: () {},
);
}
...