How to manually import extension functions when using Jetpack Compose 1.0.0-alpha11?
Asked Answered
D

1

5

I have a List<Item> that I want to be displayed using Jetpack Compose. In version "1.0.0-alpha10", this code:

@Composable
fun ItemsScreen(items: List<Item>) {
    item?.let {
        LazyColumn {
            items(
                    items = items
            ) { item ->
                ItemCard(item = item)
            }
        }
    }
}

Works fine, but, starting with "1.0.0-alpha11", according to the new updates:

New items(count: Int) factory method for scope of LazyColumn/LazyRow/LazyVerticalGrid. items(items: List) and itemsIndexed(items: List) are now extension functions so you have to manually import them when used.

My app doesn't work any more. I'm not sure I understand:

items(items: List) are now extension functions so you have to manually import.

What does it mean? How to solve this issue?

Thanks in advance.

Dichlorodifluoromethane answered 4/2, 2021 at 10:6 Comment(0)
C
8

You need to add this import for the extension function LazyListScope.items():

import androidx.compose.foundation.lazy.items
Che answered 4/2, 2021 at 11:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.