Cannot find extension method: "Cannot find a parameter with this name"

Viewed 846

Using Jetpack Compose, I'm trying to us the LazyListScope.items(..) that takes an items List.

val messages: List<Message> = ...
LazyColumn {
  items(items = messages) { message ->
    MessageCard(message)
  }
}

Cannot find a parameter with this name: items

The tutorial doesn't specify the items parameter name, but without it, Kotlin only finds the LazyListScope.items(..) that expects a count:

Type mismatch: inferred type is List but Int was expected

1 Answers

The items extension methods have to be imported:

import androidx.compose.foundation.lazy.items

With that, the items = parameter name is not explicitly necessary, as the List<Message> type has a distinct function prototype match.

Related