Anyone have any advice on how to calculate how man...
# compose
j
Anyone have any advice on how to calculate how many items are visible in the first row of a
FlowRow?
I am using a
FlowRow
, but I want to use another component when there is only a single item in the first row of the
FlowRow
.
All my items have the same size, so maybe a flowrow is not the correct tool for my implementation? I was using a
LazyGrid
at first, so maybe that is the more correct choice?
m
You could use a custom layout.
j
I was using
BoxWithConstraints
and then I had a formula
Copy code
cardsPerRow = (parentMaxWidth + spacing)/(width + spacing)
but it didn't work. After looking into the FlowLayout code I think there is a rounding error in the DP to px conversion. I will look into your suggestion @Marcin Wisniowski, with a completely custom layout for all the logic. Considering how complex the FlowRow code is, I think it will be a challenge to reproduce it and add extra logic, but might learn a lot.
m
It’s likely the FlowRow code is complex because it has to work in the general case. Your custom layout will likely be much simpler because it will only do exactly what you need it for.
👍 1