I have two types of items in LazyColumn, I am usin...
# compose
n
I have two types of items in LazyColumn, I am using sealed class to differentiate between them in this way
Copy code
modelItems.forEach { parendIndex, currentItem->
    when(currentItem.type) {
      Type1-> item { Content(currentItem) }
      Type2-> items(currentItem) {
        ParentContent(currentItem.parentData)
        ChildContent(currentItem.childData)
      }
    }
  }
problem is that, I can't pass modelItems directly to items fun in the first case, I have to render single block using forEach, which I think is not good, is there a better way of handling this, or should I just create a different screen for another List ?
z
I think this is fine,
items
just basically calls forEach over the list anyway.
👍 2
m
In case you're facing performance issues with this approach, try adding the
contentType
parameter to your call to
item(s)
contentType - the type of the content of this item. The item compositions of the same type could be reused more efficiently. Note that null is a valid type and items of such type will be considered compatible.
1