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

Hatice Sarp

02/01/2021, 11:30 AM
In alpha-09 and compose paging alpha-05, I was collecting like in the code snippet below:
Copy code
val paginatedBlockedUsers = settingsViewModel.fetchBlockedUsers().collectAsLazyPagingItems()
 LazyColumn {
    itemsIndexed(paginatedBlockedUsers) { index, item ->
        if (item != null) {
            UserListItem(
                item = item
            )
        }
    }
After upgrading from Alpha 9 to Alpha 11 when paging is on alpha-05, I get following error:
Copy code
one of the following functions can be called with the arguments supplied:
public inline fun <T> LazyListScope.itemsIndexed(items: Array<TypeVariable(T)>, crossinline itemContent: LazyItemScope.(index: Int, item: TypeVariable(T)) -> Unit): Unit defined in androidx.compose.foundation.lazy
public inline fun <T> LazyListScope.itemsIndexed(items: List<TypeVariable(T)>, crossinline itemContent: LazyItemScope.(index: Int, item: TypeVariable(T)) -> Unit): Unit defined in androidx.compose.foundation.lazy
How do I use .collectAsLazyPagingItems() and itemsIndexed(paginatedItem) { index, item -> } in alpha 11 ?
c

Cyril Find

02/01/2021, 12:01 PM
you should probably just check your imports should be something like
import androidx.compose.foundation.lazy.items
h

Hatice Sarp

02/01/2021, 12:43 PM
I have already checked my imports, here they are:
Copy code
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.paging.LoadState
import androidx.paging.compose.collectAsLazyPagingItems
import androidx.paging.compose.itemsIndexed
c

Cyril Find

02/01/2021, 12:45 PM
oh and did you also update compose paging to alpha06 ?
h

Hatice Sarp

02/01/2021, 2:10 PM
I didn't understand but it was resolved. I didn't change anything 🙂
😅 1
12 Views