I am learning LazyColum in jetpack compose. I want to add Separator in my each item in some condition, please have a look on below MessageList() function. Also I'll add a screenshot to clearly understand what I want. Please make a function reusable. Condions are as follow:-
1. Top and Bottom Separator.
2 Without separator in both Top and Bottom
But problem is that I don't know in idiomatic way in jetpack compose. I did this in Xml using Recyclerview.
import androidx.compose.foundation.lazy.items
@Composable
fun MessageList(messages: List<Message>) {
LazyColumn {
items(messages) { message ->
MessageRow(message)
}
}
}
Can you guys help me on this? Many Thanks


Just make it part of your item
If you want to add it only on the top/bottom of the list you can use item:
To make it conditional use itemsIndexed