Anm
Anm

Reputation: 3361

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

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

Upvotes: 2

Views: 2726

Answers (1)

Anm
Anm

Reputation: 3361

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.

Upvotes: 4

Related Questions