https://kotlinlang.org logo
#compose
Title
# compose
t

Tony Kazanjian

01/29/2021, 9:46 PM
Hey all. So before the alpha 11 update, I was using a 
ScrollableColumn
 to display a list of a set number of items, i.e.:
Copy code
ScrollableColumn(modifier.padding(bottom = 56.dp)) {
    collections.forEach {
        ProductCollection(collection = it)
    }
}
The 
ProductCollection
 essentially contains a composable that is a 
LazyRow
 for showing 
LazyPagingItems
Copy code
@Composable
fun ProductItemListWithId(
        collectionId: Int,
        modifier: Modifier = Modifier,
        content: @Composable LazyItemScope.(ProductItem) -> Unit){
    val viewModel: ProductListViewModel = getViewModel()

    val products = viewModel.getPagingFlowForCollection(collectionId).collectAsLazyPagingItems()
    LazyRow{
        items(products){
            product -> product?.let { content(it) }
        }
    }
}
ScrollableColumn
has been deprecated now, but it's only the row items that I want lazy loaded. Trying to use a
LazyColumn
a la :
Copy code
LazyColumn(
        modifier = modifier.padding(bottom = 56.dp)) {
        item {
            collections.forEach {
                ProductCollection(it)
            }
        }
    }
Results in the row items not always getting loaded since they are coming from a
Flow<PagingData>
that is fired lazily. What can I do to work around this, or to just simply make a normal
Column
scrollable again in Alpha 11?
Nevermind, looks like I answered my own question by actually paying attention to the documentation 😅
Copy code
Column(modifier.verticalScroll(rememberScrollState()).padding(bottom = 56.dp)) {
        ...
    }