I have a list thay displays elements with different heights (it can be also zero which mean the element is hidden), and I have a slider that controls the heights if the elements using a certain equation. The problem is, if I am standing on the 15th element for example, and i start increasing the height of the elements, the elements in the positions 0,...,14 "start pushing" the 15th element down in the list and I end up losing my position. I tried using the jumpTo method of the scroll controller but the problem is because rhe heights are different, I cannot calculate the exact offsset that I need. Is there a way to fix this problem?
I tried calculating the offsset but it did not work fine.
It can indeed be challenging. One possible approach is to estimate element height and use
jumpTomethod to scroll to estimated offset.Calculate the estimated offset by summarizing heights above the current position. Determine a buffer or padding to prevent close-up scrolling. Apply the offset using the
jumpTomethod of theScrollController.You can try this example