I have a client config that is on a server in JSON format.
example JSON would be like { \"icon\" : \"facebook\" }
I have the widget below.
Just follow the below steps to achieve.
Download the package [icons_helper]: https://pub.dev/packages/icons_helper from flutter packages
Just add below code wherever you want a dynamic icon using JSON.
a) FontAwesome icon: getIconGuessFavorFA(name:"ICON_NAME")
b) Material icon: getIconGuessFavorMaterial(name:"ICON_NAME")
Example:
ExpansionTile(
leading: Icon(getIconGuessFavorMaterial(name:root.menuIcon)), //Icon(FontAwesomeIcons.dashcube),
key: PageStorageKey(root),
title: Text(root.menuName),
children: root.children.map(_buildTiles).toList(),
)
Note: If you face any error while complying like ('Error: Getter not found: 'haykal'.'). Just comment on the icon in 'icons_helper.dart'