skip to Main Content

I have API and its return the name of fontAwsome icon like below

                    "value": 1,
                    "feature": {
                        "title": "WC"
                        "image": " fa-toilet",
                        "VIP": 6,
                    }

and I need to change image to Font Awesome Icons

I know one way that is we need create an map and define on that what icon belong to what string
like this

Map<String,IconData> icons = {
'fa-toilet': FontAwesomeIcons.toilet
};

but I need another way

HELP plz

2

Answers


  1. Chosen as BEST ANSWER

    I found something :D

    if in API we have unicode of icons we can show its easily I think its best and easy way

    with this function you can change unicode to icon ↓↓

    ourIcon(String unicode) {
    
    return IconDataSolid(int.parse(unicode,radix: 16));
    
    }
    

    1. Fork the font_awesome_flutter repository from GitHub
    2. Clone and open the project in your local
    3. Run ./util/configurator.sh --dynamic on terminal
    4. Commit and push the changes
    5. Depend on your package with git dependency
    6. Use the icon like this:
      FaIcon(faIconNameMapping['solid toolbox'])
      

    Notice that you have to add its style before the icon name (for example, solid).

    You may also need to build your app with the --no-tree-shake-icons flag.


    Reference:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search