DEV Community

Cover image for How I migrated the icon font generation in my Flutter app and why
Rodrigo Castro
Rodrigo Castro

Posted on

How I migrated the icon font generation in my Flutter app and why

Versão em Português:

In the project I'm currently working on, we use a font just for icons. One way we found to generate these fonts was to submit all the SVGs to

The process basically involved:
1) Getting the SVG from the designer
2) Updating the site with the latest config.json
3) Inserting the new icon
4) Downloading the updated icon font
5) Copy and replace the new files (font, config.json and icons.dart) into the project, which sometimes required adjusting some things manually.

What are the problems with this approach?

Our team currently consists of 5 Flutter developers and sometimes developers would create PRs where they both added icons and of course there were conflicts when it came to resolving these merges. The first developer to submit their changes would do fine, while the next person would have to deal with the conflicts manually, sometimes it was better to redo the whole process mentioned above, to resolve the conflicts more easily. I think this problem happened to me a few times and so I tried to find a more efficient way of doing this process.

Which approaches should I take?

Searching for alternatives to improve this process, making it easier to generate the icons by thinking about automating most of the process, I found this lib dart that "under the hood" uses nodeJS to generate the icons, and I realized that the result was exactly what we were expecting, but it would solve everything in a command line to generate, without the need to open the Flutter Icon site. All we would need to input was the folder with all the SVGs to be able to generate our font locally.

There was just one small problem...

Where are my SVGs?

Right at the start I ran into a very big problem. The SVG icons are used to generate the font and configuration files, but there's no way to download the SVGs back from

That's when I came across an excellent article by a developer called Sara, on how to retrieve SVG files from font-generating sites. It wasn't exactly about, but it was something that caught my eye.

Link to her article:

Reading more about the article I realized that Flutter Icon is a fork of Fontello, one of the sites mentioned by Sara in the article.

Briefly, following the article:
1) upload the FlutterIcon config.json file in Fontello
2) download the fonts from Fontello
3) Import the Fontello fonts into
4) Select all the icons and download them in SVG format

This way I got the SVGs back, whew!

Putting the Icon Font Generator package to work

First I installed IconFontGenerator as global

dart pub get activate icon_font_generator
Enter fullscreen mode Exit fullscreen mode

Next, I downloaded NodeJS via brew (MacOS):

brew install node
Enter fullscreen mode Exit fullscreen mode

Just to be sure, I checked to see if it was pointing correctly (what was expected was something like /opt/homebrew/bin/node).

which node
Enter fullscreen mode Exit fullscreen mode


$ /opt/homebrew/opt/node@18/bin/node
Enter fullscreen mode Exit fullscreen mode

Perfect, the last step is to run the icon_font_generator:

icon_font_generator --from=./assets/icons/svg --class-name=MyProjectIcons --out-font=./assets/icons/MyProjectIcons.ttf --out-flutter=./assets/icons/MyProject_icons.dart --naming-strategy=camel
Enter fullscreen mode Exit fullscreen mode

Everything worked, and now our icon font generation process is much simpler and faster.

I hope this has helped you

Until next time,

Top comments (0)