https://kotlinlang.org logo
#compose
Title
# compose
t

Tower Guidev2

01/17/2023, 3:04 PM
Good Afternoon I am investigating compose
androidx.compose.material.SwipeToDismiss
within my android applications lists on one particular list i would like to restrict my users to only being able to swipe manually Left to Right however I would also like to programmatically swipe Right to Left on the same list is this possible ?
i tried configuring my swipe to dismiss as follows:-
Copy code
SwipeToDismiss(
    state = dismissState,
    modifier = Modifier.padding(horizontal = 4.dp),
    dismissThresholds = { FractionalThreshold(0.3f) },
    background = { SwipeToDismissOrSaveBackground(dismissState, this) },
    directions = setOf(DismissDirection.EndToStart),
    dismissContent = {
        Box(Modifier.animateItemPlacement()) {
            ContentItemCard(dismissState, item, onClick, onShare, onSwipeRight)
        }
    }
)
however when i programmatically swipe StartToEnd i get the following exception
FATAL EXCEPTION: main Process: com.elsevier.practiceupdate, PID: 26240
java.lang.IllegalArgumentException: The target value must have an associated anchor.
at androidx.compose.material.SwipeableState$animateTo$2.emit(Swipeable.kt:332)
at androidx.compose.material.SwipeableState$animateTo$2.emit(Swipeable.kt:329)
at kotlinx.coroutines.flow.FlowKt__LimitKt.emitAbort$FlowKt__LimitKt(Limit.kt:73)
5 Views