Issue
how to convert String value to Icons value in Flutter, i'm getting Icon value from json as a String.
I got following error when i'm tried to Use that value
error: The argument type 'String' can't be assigned to the parameter type 'IconData'. (argument_type_not_assignable at [hippo] lib\screens\dynamic_list.dart:71)
{
"page": 1,
"MenuItems": [
{
"id": 419701,
"icon": "MdiIcons.account",
"name": "account"
},
{
"id": 419702,
"icon": "MdiIcons.currencyUsd",
"name": "Funds"
},
{
"id": 419703,
"icon": "MdiIcons.home",
"name": "home"
}
]
}
Solution
one way is that you can generate images to font icon (Generate to font). save ttf file in assets. pass unicode data to json (like "e90a").
for example:
Icon(IconData(int.parse('0x${e90a}',
fontFamily: 'family name given in the link above'));
Answered By - Mary
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.