I'm still learning compose/kotlin and have come up with a problem that seems very common, but I can't find a solution.
I have a LazyColumn with animation--that works great for making additions and subtractions from the LazyColumn visible and attractive. But I want to have a very complicated items. They are very unwieldy, so I naturally want to have them in their own function.
But when I move the item content to a separate composable function, the inner function doesn't know how to deal with animateItemPlacement().
Here is my (simplified) code for the composable function with the LazyColumn
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun LazyColumnAnimExample(
stringList: List<String>,
modifier: Modifier
) {
LazyColumn(
modifier = modifier
.padding(top = 62.dp)
) {
stringList.forEach { str ->
item(key = str) {
ComplicatedItemDraw(str)
}
}
}
}
And here is the function (greatly simplified) that draws each item
@Composable
fun ComplicatedItemDraw(text: String) {
Text(
text = text,
style = MaterialTheme.typography.headlineLarge,
modifier = Modifier
.animateItemPlacement() // error
)
}
The error message is "Unresolved reference: animateItemPlacement"
There has to be a way around this--probably something simple.