fluttercommunity / font_awesome_flutter

The Font Awesome Icon pack available as Flutter Icons
Other
831 stars 233 forks source link

Find Icon via Query String #226

Closed MatthewJones517 closed 1 year ago

MatthewJones517 commented 1 year ago

We are pulling data from an external system. Our marketing team needs to be able to specify the icon used via the backend. We don't want to push out app updates for this. They need to be able to create a new item, specify an icon for it, and immediately push.

The simplest solution would be to give them a limited pool, but we all know how that goes. ;)

I need a way of querying the icon library with a string (received via JSON) and displaying the result.

After considering multiple approaches on how to do this, it seems like this capability that should be included with the package itself. I'm not jazzed about the alternatives.

If I'm having this issue, I suspect the solution may benefit others. Hence the pull request. Thanks in advance for giving it consideration. :)

One note on implementation... The obvious question is "what happens if the query doesn't find anything?" I decided to throw an exception here. For us, we'll just display a default icon when this happens. Throwing an exception lets each project implement its own fallback behavior.

michaelspiss commented 1 year ago

Hi Matthew, thank you very much for this pull request. I personally love those "I did some work and want to save others from having to do it again" ones!

However, I may have bad news for you, as we already support this functionality. Please have a look at this section in the readme: retrieve icons dynamically by their name or css class for information about to how to enable it and why it is disabled by default.

On the other hand, I like your approach with throwing an exception better than ours. The current implementation just returns the question mark icon.

MatthewJones517 commented 1 year ago

You know... If there's one thing I pride myself on it's my ability to throughly read documentation. 😂 I can't believe I missed that. lol!

I'm going to go ahead and close this PR. Thanks for reviewing!