For a FlowRow filled with Text and Dividers (imagine something like: TEXT | TEXT | TEXT | TEXT | TEXT) spanning multiple rows, I want to avoid a divider item being the first or last item in a row. What's the best way to achieve this? Right now I can only think of measuring all items to see if they fit a row, but then again, FlowRow should already handle this, so maybe a custom implementation based on FlowRow with a separate step during measurement is the only way to go?
y
youssef hachicha
07/09/2024, 8:17 PM
Copy code
val textList = listOf("test", "test")
@Composable
fun TextWithDivider(
text: String,
index: Int,
){
Text(text = text)
if (index != textList.lastIndex)
Divider()
}
FlowRow {
textList.forEachIndexed { index, text ->
TextWithDivider(text,index)
}
}
s
Stylianos Gakis
07/09/2024, 8:55 PM
I want to avoid a divider item being the first or last item in a row.
Read the post again @youssef hachicha , this isn't only for the last item, but also for the first item in a row.