-
-
Notifications
You must be signed in to change notification settings - Fork 68
[How to use] Preserve the position to index when load more #115
Copy link
Copy link
Closed
Description
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:
Widget resultWidget = Listener(
onPointerSignal: (e) {
if ((e is PointerScrollEvent && scrollController.offset == 0 && e.scrollDelta.dy > 0)
|| (e is PointerScrollInertiaCancelEvent && scrollController.offset == 0) ) {
print("load at bottom");
_addMessage(RandomTool.genInt(min: 3, max: 5));
}
},
child: ListView.builder(
physics: chatObserver.isShrinkWrap
? const NeverScrollableScrollPhysics()
: scrollViewPhysics,
padding: const EdgeInsets.only(
left: 10,
right: 10,
top: 15,
bottom: 15,
),
shrinkWrap: chatObserver.isShrinkWrap,
reverse: true,
controller: scrollController,
itemBuilder: ((context, index) {
return ChatItemWidget(
chatModel: chatModels[index],
index: index,
itemCount: chatModels.length,
onRemove: () {
chatObserver.standby(isRemove: true);
setState(() {
chatModels.removeAt(index);
});
},
);
}),
itemCount: chatModels.length,
),
);
Try do it
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels