remember { mutableListOf(...) } retains a list, but an ordinary list does not notify Compose when its elements change. Retaining an object and observing its mutations are separate concerns.
For simple local UI state, replace the list value:
var topics by remember { mutableStateOf(listOf("Lifecycle")) }
Button(onClick = { topics = topics + "Saved state" }) {
Text("Add topic")
}
topics.forEach { topic -> Text(topic) }
Another option is remember { mutableStateListOf<String>() }, whose structural mutations are observable. Choose one model consistently instead of mixing an observable wrapper with hidden mutable internals.
Putting a mutable list inside a data class does not make its contents observable. Mutating that list and assigning the same object back can also fail to produce a distinguishable new state. Prefer immutable items and a new list when publishing screen state from a ViewModel.
What if the list updates but a lesson title does not? Inspect the lesson object. A plain mutable title property inside an observable list is not automatically observable. Replace the lesson with an updated immutable value, or deliberately make the relevant property observable.
Mark this when you can explain the answer in your own words.
Help fellow developers prepare for interviews
Sharing helps the Android community grow ๐