Why can't we have a `spacing` parameter for the `i...
# compose
k
Why can't we have a
spacing
parameter for the
items
in
LazyColumn
, it's very convenient.
z
You got one:
verticalArrangement = spacedBy(…)
💯 1
2
k
But I want different items have different spacings.
a
If it's for different items, then I guess it's better if it is taken care for in the
item
section
j
I could have an
item
that has a
Column
with different sizing, but then the items in that column aren't lazy 🤔
a
what I mean is this
Copy code
LazyColumn {
  items(data) { item ->
    Item(
        modifier = Modifier.padding(
           top = when(item) {
               is ItemA -> 10.dp
               is ItemB -> 13.dp
               else     -> 5.dp
           }
        )
    )
  }
}
Because, asking to have spacing parameter on the
LazyColum
itself, and each item requiring a different spacing, would result into a very ugly API
👍 2
k
I meant
items(list, spacing = 8.dp) {}
Or I have to use
itemsIndexed
with
Spacer
in the item, it's too duplicated
a
Copy code
LazyList(
  arrangement = Arrangement.spacedBy(8.dp)
) {
  items(list) {
    // hour code here
  }
}
Doesn't this fit your use case?
j
I think they're looking for per-region sizes
Copy code
LazyList {
  items(list1, arrangement = Arrangement.spacedBy(8.dp)) {
    // hour code here
  }
  items(list2, arrangement = Arrangement.spacedBy(16.dp)) {
    // hour code here
  }
}
a
Oooh, I see. Is that the case @Kyant?
k
Yes, the per-items spacing
a
oooh, if that's the case, then I agree with you, I think something can be improved there especially without ruining the API