I'm trying to animate adding/removing items from a LazyList. This post suggests that I use LazyItemScope$Modifier.animateItemPlacement() but I am running into issues.
I am using Jetpack Compose version 1.1.0-beta03. Here is a snippet of the code I'm using:
@ExperimentalFoundationApi
@ExperimentalAnimationApi
@ExperimentalMaterialApi
@Composable
fun NotificationList(
listState: LazyListState,
notifications: List<Notification>
) {
Surface(modifier = Modifier.fillMaxSize()) {
LazyColumn(state = listState) {
itemsIndexed(
items = notifications,
key = { _, listItem -> listItem.hashCode() }
) { _, notification ->
// ...
SwipeToDismiss(
modifier = Modifier.animateItemPlacement(),
// ...
)
}
}
}
}
However, my app crashes when launched. Below is what I see in the console. Does anyone know what I'm doing wrong or how to fix it?
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.somecompany.someapp, PID: 22108 java.lang.NoSuchMethodError: No static method AnimatedContent(Landroidx/compose/animation/core/Transition;Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function1;Landroidx/compose/ui/Alignment;Lkotlin/jvm/functions/Function4;Landroidx/compose/runtime/Composer;II)V in class Landroidx/compose/animation/AnimatedContentKt; or its super classes (declaration of 'androidx.compose.animation.AnimatedContentKt' appears in /data/app/com.somecompany.someapp-zQWcLTjkBOQqglBKnmHLIg==/base.apk) at com.google.accompanist.navigation.animation.AnimatedNavHostKt.AnimatedNavHost(AnimatedNavHost.kt:242) at com.somecompany.someapp.MainActivity2$onCreate$1$1$1$5.invoke(MainActivity2.kt:78) at ...