Kotlin newbie here!
I'm trying to make a map that can be changed, but also where such a change will trigger recomposition. However, I'm hitting a conundrum and can't seem to find a way around it.
I understand that using something like this:
val someVar by remember {mutableStateOf(someMutableMap)}
is useless because it's trying to view a mutable state of objects which are themselves mutable. I understand why this doesn't work. However, I can't seem to find a way to use mutableStateOf() with a plain map because if I use a plain map, there's no way to add key / value pairs or to change the values once they're there. Makes sense, since that's what immutable means. But I need to be able to add to and change the map due to the nature of the app I'm trying to write.
I've tried:
-> Using a mutableStateOf(mutableMap), which gives me a warning about using mutable state on something that is itself mutable. This doesn't trigger recomposition, for obvious reasons.
-> Using a mutableStateOf(map), which does trigger recomposition, however, it also prevents me from adding to or changing the map, since there aren't any setters for immutable objects. This causes the function that builds the map (from a text file, but one headache at a time) to not work, along with basically everything else about the app, since the whole point is for the user to build this map.
I'm not expecting a silver-platter answer, but a little direction would be vastly appreciated. I can post code here if it will help.