Arthur
10/02/2026, 2:00 AMException in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Corner size in Px can't be negative(topStart = -0.14431858, topEnd = -0.14431858, bottomEnd = 32.048107, bottomStart = 32.048107)!
at androidx.compose.foundation.internal.InlineClassHelperKt.throwIllegalArgumentException(InlineClassHelper.kt:34)
at androidx.compose.foundation.shape.CornerBasedShape.createOutline-Pq9zytI(CornerBasedShape.kt:125)
at androidx.compose.material3.internal.AnimatedShapeKt$rememberAnimatedShape$1$1.createOutline-Pq9zytI(AnimatedShape.kt:137)
I was using it with the latest material3 1.13.0-alpha01 but i had experience this before with the `1.12.0-alpha03`` the last version it was working fine for me was the 1.12.0-alpha02Arthur
10/02/2026, 2:00 AM@Composable
public fun itemShape(
index: Int,
totalItems: Int,
cornerRadius: Dp = 16.dp,
): Shape {
val shape = remember(index, totalItems, cornerRadius) {
val top = if (index == 0) cornerRadius else 0.dp
val bottom = if (index == totalItems - 1) cornerRadius else 0.dp
RoundedCornerShape(top, top, bottom, bottom)
}
return shape
}
@Composable
public fun segmentedListItemShape(
index: Int,
totalItems: Int,
cornerRadius: Dp = 16.dp,
): ListItemShapes {
val shape = itemShape(
index = index,
totalItems = totalItems,
cornerRadius = cornerRadius,
)
return ListItemDefaults.segmentedShapes(
index = index,
count = totalItems,
defaultShapes = shapes().copy(
shape = shape,
),
)
}Arthur
10/02/2026, 2:05 AMArthur
10/02/2026, 4:00 AM