Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discussions] How to define cacheExtent to jump correct position? #83

Closed
thaidmfinnick opened this issue May 22, 2024 · 2 comments
Closed
Assignees

Comments

@thaidmfinnick
Copy link

Content

Hi again,
I use flutter_scrollview_observer for rendering list messages, and my case is after I jump to specific message, I want to back to latest message, but when I use jumpTo(index: 0), it's wrong in some cases.

Now, I set cache extent is very large: 9999999999. But if I don't set cache extent, the jumping is not correct anymore.
I have followed wiki, but not clear about reasonable value you mention.

My snippet code below:

// load API when scroll to latest message
MessageChannelController.getMessageChannelUp(token, widget.selectedChannelId, selectedWorkspaceId, isNotifyListeners: true, limit: 30).then((v) {
   // when loaded
    final obItem = observerController.observeItem(index: 0);
    print('0: ${obItem?.scrollOffset} --- ${obItem?.displayPercentage}');
    observerController.jumpTo(index: 0);
    print(observerController.controller?.offset);
});
@LinXunFeng
Copy link
Member

Can you provide a demo that reproduces the problem?

It is recommended to use the following code to back to latest message, so that there is no need to go through redundant calculations inside scrollview_observer.

scrollController.animateTo(
0,
duration: const Duration(milliseconds: 300),
curve: Curves.easeInOut,
);

@thaidmfinnick
Copy link
Author

Sorry for my late response. Using animate to works as expected. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants