Limbou / expandable_page_view

MIT License
86 stars 36 forks source link

Support useMaxSize param #43

Closed minhdanh closed 2 years ago

minhdanh commented 2 years ago

This PR allows the size of all children to be set as the same with the maximum size. It helps in case we don't want the screen auto resized with other widgets when switching between pages.

Limbou commented 2 years ago

Hi @minhdanh thanks for your contribution.

I have some doubts if this library should support the feature you requested. I believe this is a slightly different use case, not what I had in mind when implementing it.

Additionally, the solution you suggested for ExpandablePageView will not work properly in a case, when the largest child is somewhere further down the list of children. Let's consider a following example:

We have a list of 5 children with sizes: [50, 100, 150, 200, 250]. By default ExpandablePageView will start at index zero, knowing only the size of the first child, so it will set its height to 50. After we try to scroll to the next child, it will discover that the second child is actually bigger, so it will set its height to 100. The same goes for every other child. So my point is here that ExpandablePageView will never match the size of the biggest child until it scrolled through all of them, because before that sizes of that children are not fully known. Here is a screen recording showcasing the problem:

https://user-images.githubusercontent.com/29557232/184242881-42cd1b85-6388-4ed8-950a-12f877775aff.mp4

I believe that even if we found a way to solve this problem for a regular ExpandablePageView, it will be much harder to do for ExpandablePageView.builder, as it doesn't render any children invisible on the screen at the time.

To summarize, I will close this pull request for now, as I believe requested feature is a different use case that could maybe find its place in a different library.

minhdanh commented 2 years ago

Thanks @Limbou for the explanation.