fluttercommunity / font_awesome_flutter

The Font Awesome Icon pack available as Flutter Icons
Other
844 stars 244 forks source link

Need help parsing icons #172

Closed Sembauke closed 3 years ago

Sembauke commented 3 years ago

I get FontAwesome Icons dynamically from an API named Discourse, they supply me these icon names as strings. I am trying to parse these strings so I can return them as an Icon:

image

Is there any way to accomplish this?

michaelspiss commented 3 years ago

Hi, you may want to have a look at #102. It requires some work on your end, however. If you have a limited set of possible returned icon names, you can also consider to create a mapping "icon name" => FaIcon(...), which further optimizes the code and does not require you to disable font tree shaking and thus to ship all icons to the end user.

Sembauke commented 3 years ago

I want to parse icons dynamically, so mapping them would not be an option.

Sembauke commented 3 years ago

Can you explain to me what this does exactly? https://github.com/fluttercommunity/font_awesome_flutter/blob/icon-map/tool/generate_icon_map.dart

michaelspiss commented 3 years ago

It creates the "icon name" => FaIcon(...) mapping for all available icons for you. This way you can use the icons by their name or even search for them. You can then use the package like icon: icons["icon name"]

Mythar commented 3 years ago

You can try my new package :)

Link: flutter_font_awesome_web_names

Sembauke commented 3 years ago

Hey @Mythar,

Thank you for this, it is going to help a lot!