https://kotlinlang.org logo
l

Louis

06/11/2023, 12:47 PM
Hello, is there a way to transform a string to a resource for example "Icons.Rounded.Settings".toImageVector() would returns Icons.Rounded.Settings?
not sure it's especially compose channel but it's about compose icons so...
z

Zun

06/11/2023, 8:50 PM
What’s your use case for wanting this? Server driven UI?
z

Zach Klippenstein (he/him) [MOD]

06/12/2023, 1:36 AM
You could parse the string then use reflection to look up the members. But i wouldn’t recommend doing this: it’s brittle and slow due to reflection. Instead hard-code the mapping of names to icons that you need.
l

Louis

06/12/2023, 7:28 AM
Yeah @Zun exactly this
@Zach Klippenstein (he/him) [MOD] I thought about this but wondering if there was a better way, thanks anyway 🙏