You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
View the Flutter app in the `example` directory to see all the available `FontAwesomeIcons`.
56
56
57
-
## FAQ
58
-
59
-
### Why aren't the icons aligned properly or why are the icons being cut off?
60
-
61
-
Please use the `FaIcon` widget provided by the library instead of the `Icon`
62
-
widget provided by Flutter. The `Icon` widget assumes all icons are square, but
63
-
many Font Awesome Icons are not.
57
+
## Customizing font awesome flutter
64
58
65
-
### What about file size
66
-
This package has been written in a way so that it only uses the minimum amount of resources required.
59
+
We supply a configurator tool to assist you with common customizations to this package.
60
+
All options are interoperable.
61
+
By default, if run without arguments and no `icons.json` in `lib/fonts` exists, it updates all icons to the
62
+
newest free version of font awesome.
67
63
68
-
All links (eg. `FontAwesomeIcons.abacus`) to unused icons will be removed automatically, which means only required icon
69
-
definitions are loaded into ram.
64
+
### Setup
65
+
To use your custom version, you must first clone [this repository](https://github.com/fluttercommunity/font_awesome_flutter.git)
66
+
to a location of your choice and run `flutter pub get` inside. This installs all dependencies.
70
67
71
-
Flutter 1.22 added icon tree shaking. This means unused icon "images" will be removed as well. However, this only
72
-
applies to styles of which at least one icon has been used. Assuming only icons of style "regular" are being used,
73
-
"regular" will be minified and "solid" and "brands" will stay in their raw, complete form. This issue is being [tracked
74
-
over in the flutter repository](https://github.com/flutter/flutter/issues/64106). While it is open, a workaround is
75
-
to create an icon of each style and put it in an invisible container.
68
+
The configurator is located in the `util` folder and can be started by running `configurator.bat` on Windows, or
69
+
`configurator.sh` on linux. All following examples use the `.sh` version, but are exactly the same for `.bat`.
70
+
An overview of available options can be viewed with `configurator.sh --help`.
76
71
77
-
### Why aren't the icons showing up on Mobile devices?
72
+
To use your customized version in an app, go to the app's `pubspec.yaml` and add a dependency for
73
+
`font_awesome_flutter: '>= 4.7.0'`. Then override the dependency's location:
74
+
```yaml
75
+
dependencies:
76
+
font_awesome_flutter: '>= 4.7.0'
77
+
...
78
+
79
+
dependency_overrides:
80
+
font_awesome_flutter:
81
+
path: /path/to/your/font_awesome_flutter
82
+
...
83
+
```
78
84
79
-
If you're not seeing any icons at all, sometimes it means that Flutter has a cached version of the app on device and hasn't pushed the new fonts. I've run into that as well a few times...
85
+
### Enable pro icons
86
+
:exclamation: By importing pro icons you acknowledge that it is your obligation
87
+
to keep these files private. This includes **not** uploading your package to
88
+
a public github repository or other public file sharing services.
80
89
81
-
Please try:
90
+
* Go to the location of your custom font_awesome_flutter version (see [setup](#setup))
91
+
* Download the web version of font awesome pro and open it
92
+
* Move **all**`.ttf` files from the `webfonts` directory and `icons.json` from `metadata` to
* Run the configurator. It should say "Custom icons.json found"
82
95
83
-
1. Stopping the app
84
-
2. Running `flutter clean` in your app directory
85
-
3. Deleting the app from your simulator / emulator / device
86
-
4. Rebuild & Deploy the app.
96
+
It may be required to run `flutter clean` in apps who use this version for changes to appear.
87
97
88
-
### Why aren't the icons showing up on Web?
98
+
### Excluding styles
99
+
One or more styles can be excluded from all generation processes by passing them with the `--exclude` option:
100
+
```
101
+
$ configurator.sh --exclude solid
102
+
$ configurator.sh --exclude solid,brands
103
+
```
89
104
90
-
Most likely, the fonts were not correctly added to the `FontManifest.json`.
91
-
Note: older versions of Flutter did not properly package non-Material fonts
92
-
in the `FontManifest.json` during the build step, but that issue has been
93
-
resolved and this shouldn't be much of a problem these days.
105
+
See the [optimizations](#what-about-file-size-and-ram-usage) and [dynamic icon retrieval by name](#retrieve-icons-dynamically-by-their-name-or-css-class)
106
+
sections for more information as to why it makes sense for your app.
94
107
95
-
Please ensure you are using `Flutter 1.14.6 beta` or newer!
108
+
### Retrieve icons dynamically by their name or css class
109
+
Probably the most requested feature after support for pro icons is the ability to retrieve an icon by their name.
110
+
This was previously not possible, because a mapping from name to icon would break all
111
+
[discussed optimizations](#what-about-file-size-and-ram-usage). Please bear in mind that this is still the case.
112
+
As all icons could theoretically be requested, none can be removed by flutter. It is strongly advised to only use this
113
+
option in conjunction with [a limited set of styles](#excluding-styles) and with as few of them as possible. You may
114
+
need to build your app with the `--no-tree-shake-icons` flag for it to succeed.
96
115
97
-
### How can I use pro icons?
116
+
Using the new configurator tool, this is now an optional feature. Run the tool with the `--dynamic` flag to generate...
117
+
```
118
+
$ configurator.sh --dynamic
119
+
```
120
+
...and the following import to use the map. For normal icons, use `faIconMapping` with a key of this format:
121
+
'style icon-name'. For duotone icon, use `faIconMappingDuotone` - the icon name is sufficient as key.
This library only packages the free Font Awesome icon fonts. If you own the pro
100
-
icon fonts and want to use them with Flutter, please follow these instructions.
125
+
...
126
+
FaIcon(
127
+
icon: faIconMapping['solid abacus'],
128
+
);
129
+
...
130
+
```
101
131
102
-
:exclamation: By importing pro icons you acknowledge that it is your obligation
103
-
to keep these files private. This includes **not** uploading your package to
104
-
a public github repository or other public file sharing services.
132
+
To exclude unused styles combine the configurator options:
133
+
```
134
+
$ configurator.sh --dynamic --exclude solid
135
+
```
105
136
106
-
* Clone [this repository](https://github.com/fluttercommunity/font_awesome_flutter.git) to a location of your choice and go into the newly created directory.
107
-
* Remove `#`s from `pubspec.yaml` at the indicated position
108
-
* run `flutter packages get`
109
-
* Download your font awesome pro icons (web version)
110
-
* Move **all**`.ttf` files from the `webfonts` directory to `/path/to/your/font_awesome_flutter/lib/fonts` (replace existing fonts)
111
-
*_Note:_ Please make sure **all**`.ttf` files (and the following `icons.json`) are of the same version to avoid missing icons!
112
-
* Move `icons.json` from `metadata` to `/path/to/your/font_awesome_flutter`
113
-
* From there run `./tool/update.sh` on linux or `.\tool\update.bat` on windows
114
-
*_Note for windows users:_ Please run the script in cmd or powershell only. Flutter is known to have problems with third-party shells.
115
-
* Add version `>= 4.7.0` to your project's dependencies, Override it with the path to your local installation:
116
137
117
-
```yaml
118
-
dependencies:
119
-
font_awesome_flutter: '>= 4.7.0'
120
-
...
121
-
122
-
dependency_overrides:
123
-
font_awesome_flutter:
124
-
path: /path/to/your/font_awesome_flutter
125
-
...
138
+
A common use case also includes fetching css classes from a server. The utility function `getIconFromCss()` takes a
139
+
string of classes and returns the icon which would be shown by a browser:
140
+
```dart
141
+
getIconFromCss('far custom-class fa-abacus'); // returns the abacus icon in regular style. custom-class is ignored
126
142
```
127
143
128
-
###Duotone icons
144
+
## Duotone icons
129
145
130
146
Duotone icons require special treatment. Instead of `FaIcon` a special class
131
147
`FaDuotoneIcon` needs to be used. It allows to set the primary and secondary colors
132
148
for the icon. If primary and / or secondary color are not defined, they will default
133
-
to the standard `IconTheme` color. Please be aware that only duotone style icons
134
-
can be passed to this class. `FaDuotoneIcon` is only available if at least one duotone
135
-
icon is available.
149
+
to the standard `IconTheme` color. Please be aware that only duotone style icons
150
+
can be passed to this class. `FaDuotoneIcon` is only available if [at least one duotone
151
+
icon was added using the configurator](#enable-pro-icons).
136
152
137
153
138
154
```dart
@@ -142,3 +158,46 @@ FaDuotoneIcon(
142
158
secondaryColor: Colors.black,
143
159
);
144
160
```
161
+
162
+
## FAQ
163
+
164
+
### Why aren't the icons aligned properly or why are the icons being cut off?
165
+
166
+
Please use the `FaIcon` widget provided by the library instead of the `Icon`
167
+
widget provided by Flutter. The `Icon` widget assumes all icons are square, but
168
+
many Font Awesome Icons are not.
169
+
170
+
### What about file size and ram usage
171
+
This package has been written in a way so that it only uses the minimum amount of resources required.
172
+
173
+
All links (eg. `FontAwesomeIcons.abacus`) to unused icons will be removed automatically, which means only required icon
174
+
definitions are loaded into ram.
175
+
176
+
Flutter 1.22 added icon tree shaking. This means unused icon "images" will be removed as well. However, this only
177
+
applies to styles of which at least one icon has been used. Assuming only icons of style "regular" are being used,
178
+
"regular" will be minified to only include the used icons and "solid" and "brands" will stay in their raw, complete
179
+
form. This issue is being [tracked over in the flutter repository](https://github.com/flutter/flutter/issues/64106).
180
+
181
+
However, using the configurator, you can easily exclude styles from the package. For more information, see
182
+
[customizing font awesome flutter](#customizing-font-awesome-flutter)
183
+
184
+
### Why aren't the icons showing up on Mobile devices?
185
+
186
+
If you're not seeing any icons at all, sometimes it means that Flutter has a cached version of the app on device and
187
+
hasn't pushed the new fonts. I've run into that as well a few times...
188
+
189
+
Please try:
190
+
191
+
1. Stopping the app
192
+
2. Running `flutter clean` in your app directory
193
+
3. Deleting the app from your simulator / emulator / device
194
+
4. Rebuild & Deploy the app.
195
+
196
+
### Why aren't the icons showing up on Web?
197
+
198
+
Most likely, the fonts were not correctly added to the `FontManifest.json`.
199
+
Note: older versions of Flutter did not properly package non-Material fonts
200
+
in the `FontManifest.json` during the build step, but that issue has been
201
+
resolved and this shouldn't be much of a problem these days.
202
+
203
+
Please ensure you are using `Flutter 1.14.6 beta` or newer!
0 commit comments