Closed paurakhsharma closed 1 month ago
getScrollOffsetByIndex is not what I want to exposed. Because the items is dynamic created. The scroll offset is adjust after items loaded. The scroll offset is not accurate in any time.
Oh I see. Thank you for the reply @robert-luoqing . Do you have any suggestions on how I can scroll to x
offset inside a y
page.
Currently I am doing.
final offsetInsidePage = x;
final pageIndex = y;
final pageOffset = scrollController?.sliverController.getScrollOffsetByIndex(y); // because I exposed this method.
scrollController?.animateTo(
offsetInsidePage + pageOffset,
duration: const Duration(milliseconds: 500),
curve: Curves.easeIn,
);
As you said it doesn't always work because all the childrens are not build.
I was able to achieve this without getScrollOffsetByIndex()
,
I had to do
final offsetInsidePage = x;
final pageIndex = y;
scrollController?.sliverController.animateToIndex(
pageIndex,
duration: const Duration(milliseconds: 500),
curve: Curves.easeIn,
offset: -offsetInsidePage,
);
I tried it previously as well but I realise I need to give it negative offset to archive what I wanted.
Thank you for the awesome package.
I need to have access to
getScrollOffsetByIndex
to scroll to a particular offset inside the List Element. It would be great if we can expose it so that the package users can use it to calculate different scroll offsets they would require.