lesincs
12/26/2021, 4:41 PMLazyListScope
?@Composable
fun Page() {
// I have to put the Dialogs at least the same level of LazyColumn.
Dialogs()
LazyColumn {
item {
// some item
}
reusableItems()
}
}
private fun LazyListScope.reusableItems() {
items {
// reusable item
}
// it will complain because we are not in a composable scope
Dialogs()
}
In the code above, the Dialogs
is a normal composable function which is strongly related to the reusableItems
. But I just can’t put it in the reusableItems
, because it’s not in a context of composable function. So I have to move the Dialogs
out to the level which is at least as same as the`LazyColumn`’s. It works, but breaks the encapsulation.
Is there an elegant way to handle this situation?Ali Albaali
12/27/2021, 10:20 AMDialogs
call in item
block.lesincs
12/27/2021, 10:29 AMYou can wrap the secondI’ve thought about it. But it’s acall inDialogs
block.item
LazyColumn
instead of a Column
, so I think the item might be disposed when I scroll up.Ali Albaali
12/27/2021, 10:30 AMstickyHeader
lesincs
12/27/2021, 10:35 AMstickyHeaders
.