I'd like to make icons configurable. Is it possible to access the Material Icon library by name, rather than as extension properties on untyped objects? For example, something like this:
val icon = getMaterialIcon("Filled.Crop169") // would resolve to Icons.Filled.Crop169
I'd like to avoid writing a huge when
, especially since I'd have to do one for each icon type (Filled, Outlined, etc). For the record, these icons do already know what their name is. For example, Icons.Filled.Crop169
is defined as materialIcon(name = "Filled.Crop169") { ... }
. I just need a way to access them by that name.
I'm using Compose Desktop, but the answer is probably the same for Android with Jetpack Compose.