I’m trying to lazy-load items to be displayed in a
Dialog
. To achieve this, I have a state of
MutableList
which is initially empty and then populated via a
LaunchedEffect
. Even though the state is successfully updated, the Dialog does not show the items. Is this something to do with limitations in updating Dialog’s contents, or am I doing something fundamentally wrong?
Mark
02/01/2023, 9:46 AM
I’ve found a way to make it work by doing this:
Copy code
var items by remember {
mutableStateOf<List<Item>>(emptyList())
}
LaunchedEffect(true) {
items = calculateItems()
}
if (items.isNotEmpty()) {
MyDialog(items, onDismissRequest)
}
although I’m not sure why it wasn’t also working when the