Search code examples
kotlinparametersandroid-jetpack-composestatemutablestateof

printing mutableState parameters


I have a class Plan() that has the parameter "val changeNumber : MutableState<Double?>". as in Plan( ... val changeNumber : MutableState<Double?> ...

){}

I want to display this value on the screen but when I use plan.changeNumber.toString() it displays "MutableState(value = 84.0)@1593929391

How do I just access the value if I can. or do I can I not even take it as a parameter if I want it to work?

I tried getValue (which is asking for another value inside but I cannot find the correct parameter to put in there) and toString. getValue gives an error and toString displays what I put above.


Solution

  • You are displaying the instance of the MutableState. You have to call .value to get the value: plan.changeNumber.value?.toString()