With Jetpack Compose version "1.0.1" I used Badge Box like This
BadgedBox(
badgeContent = {
Text(text = "5")
},
backgroundColor = Primary,
modifier = Modifier
) {
Icon(
imageVector = Icons.Outlined.ShoppingCart,
contentDescription = "shopping cart",
tint = Color.Black
)
}
But with Compose version "1.0.5" this code doesn’t work
What is the new way to do it?
2
Answers
Using
badge
attribute ofBadgedBox
andBadge
Composable.Example,
With compose M2 (starting from
1.1.x
) and M3 you can use:Old answer:
Instead with compose M2
1.0.x
you can use:With 1.1.x the
BadgeBox
was renamed toBadgedBox
and some parameters were removed (check this commit).