How to call a composable function in a `LazyListSc...
# compose
l
How to call a composable function in a
LazyListScope
?
Copy code
@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?
a
You can wrap the second
Dialogs
call in
item
block.
l
You can wrap the second 
Dialogs
 call in 
item
 block.
I’ve thought about it. But it’s a
LazyColumn
instead of a
Column
, so I think the item might be disposed when I scroll up.
a
What about
stickyHeader
l
I think it should have the same issue, I might have multiple
stickyHeaders
.