What's the right way to delete an item in your mod...
# compose
r
What's the right way to delete an item in your model, when using
SwipeToDismiss
? The example here does not show it. I'm trying
LaunchedEffect(dismissState.currentValue) {...}
, but there is a little delay that I don't like. More in thread...
Maybe I'm asking less about how to to delete in the model, and more about how to start the animation. In the LaunchedEffect I start a delete animation if
dismissState.currentValue == DismissedToStart
. I think the delay I see is because currentValue is also animated. So I swipe to delete, then there is a fraction of a second waiting for currentValue, and then the item in the list shrinks away upward.
d
The visual delay seems like the result of a spring-based swipe animation w/ too small of a
VisibilityThreshold
- it's animating until it's within 0.01 pixel from the target, which can be perceived as a delay. It's worth filing a bug on
SwipeToDismiss
to allow customization on the swipe animation/spring animation instead of using the default. Also, the default could also benefit from a
VisibilityThreshold
specific to pixels. 🙂
r
I'm getting crashes because it will re-dismiss when I come back to the screen with the list. I was going off code example here: https://gist.github.com/bmc08gt/fca95db3bf9fcf255d76f03ec10ea3f9. Maybe that's missing a state.reset() or key() or something?
d
What is the error in the crashes?
r
It's a java.lang.IndexOutOfBoundsException. The last two frames are ArrayList.get and LazyListScope.items.
d
Could you put together a reproducible use case in a sample project and file a bug?
r
Okay, I'll try.