-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
[How to use] Preserve the position to index when load more #115
Comments
You can do this by setting the |
Thank u.
Could u give me some suggestions? |
Just make the following adjustments print("load at bottom");
chatObserver.fixedPositionOffset = -1;
- await Future.delayed(const Duration(seconds: 1));
_addMessage(RandomTool.genInt(min: 3, max: 5));
- chatObserver.fixedPositionOffset = 0;
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ chatObserver.fixedPositionOffset = 0;
+ }); |
Oh thank u. I forgot that func 😄 |
Hi @LinXunFeng. Is the max value of changeCount 10 when using chatObserver standby to make that keeping position of message effect ? |
The
|
I tried this but not worked 😓 (also mark unread @@) :
Video demo: Screen.Recording.2025-02-27.at.12.06.52.mov |
Code adjustmentIf you want to keep the position when inserting messages normally, you only need to use the following code, which will automatically calculate the index of the referenced item based on the - chatObserver.fixedPositionOffset = -1;
- await Future.delayed(const Duration(seconds: 1));
+ int count = RandomTool.genInt(min: 3, max: 5);
// int count = 30;
chatObserver.standby(
changeCount: count,
- mode: ChatScrollObserverHandleMode.specified,
- refIndexType: ChatScrollObserverRefIndexType.itemIndex,
- refItemIndex: 1,
- refItemIndexAfterUpdate: 1,
);
setState(() {
needIncrementUnreadMsgCount = true;
for (var i = 0; i < count; i++) {
chatModels.insert(0, ChatDataHelper.createChatModel());
}
});
- WidgetsBinding.instance.addPostFrameCallback((_) {
- chatObserver.fixedPositionOffset = 0;
- }); Note: By default, the Another problem is that if you insert About mode: .specifiedAs for when For example, if the offset of the ListView is chatObserver.standby(
changeCount: count,
mode: ChatScrollObserverHandleMode.specified,
refIndexType: ChatScrollObserverRefIndexType.itemIndex,
refItemIndex: 1,
- refItemIndexAfterUpdate: 1,
+ refItemIndexAfterUpdate: 1 + count,
); Related document: Specifies the referenced item |
Thank you! I had tried that before and set cacheExtent to double.maxFinite, but it didn’t work. Now, I’ve discovered that the issue was with
Could you help me to understand what isShrinkWrap in chatObserver does? Thanks a lot! 💯 |
The |
Platforms
macOS
Description
Hi.
When my chat list at the bottom and scroll down to load lastest data, the scroll bar is always at the bottom. Are there any ways to improve this case ?
Thank u.
Screen.Recording.2025-02-26.at.11.11.12.mov
My code
Based on code in example chat_page:
Try do it
No response
The text was updated successfully, but these errors were encountered: