The icon to use is a name received from server side, e.g., "lock",
How to map "lock" to Icons.lock?
Icon(Icons.lock)
Do I need to create a Map from string(name) to flutter icon constants? Expecting a static method
Icons.fromName(String name)
The icon to use is a name received from server side, e.g., "lock",
How to map "lock" to Icons.lock?
Icon(Icons.lock)
Do I need to create a Map from string(name) to flutter icon constants? Expecting a static method
Icons.fromName(String name)
4
Answers
here is an example of how you can do 🙂
No need to maintain map, what you can do is,
Instead of
use
Where
0xe3ae
needs to be passed from server, and it isint
.You can find code for each icon on
flutter/src/materials/icons.dart
.You can navigate to that file by tapping on
Icon.icon_name
on your code.You can use the simple
switch-case
method: