Closed IWantToKnowAboutThis closed 6 months ago
No, unless the height of your item is fixed.
observerController.jumpTo(index: 450, isFixedHeight: true);
Releated issue: https://github.com/fluttercandies/flutter_scrollview_observer/issues/5
My app is chat app. Of course, each item is different in height.
In the _handleScrollToIndex function, nextPageOffsetRectified is looking for it one by one, is there a way to go at once?
Only when the target item is rendered can this package calculate the corresponding offset.
Without scrolling, it is impossible for the ListView to render the item with index 450 unless the cacheExtent
is double.maxFinite
. However, if the cacheExtent
is set to double. maxFinite
, an extremely large number of items will be rendered at once. This behavior is undesirable in your scenario because it will affect performance.
There's something library super_sliver_list, and I don't know if it's jumpTo after item rendering, but it's jumpToItem directly. But I need ChatObserverClampingScrollPhysics with physics like scrollview_observer. Because chat app need to that function what fix scroll position when other person sends me a chat message.
Don’t worry, scrollview_observer
supports use with other third-party packages, as shown in the following code.
var scrollViewPhysics =
physics.applyTo(ChatObserverClampingScrollPhysics(
observer: chatObserver,
));
+ Widget resultWidget = SuperListView.builder(
physics: chatObserver.isShrinkWrap
? const NeverScrollableScrollPhysics()
: scrollViewPhysics,
shrinkWrap: chatObserver.isShrinkWrap,
reverse: true,
controller: scrollController,
itemBuilder: ((context, index) {
return ...;
}),
...,
);
resultWidget = ListViewObserver(
controller: observerController,
child: resultWidget,
+ customTargetRenderSliverType: (renderObj) {
+ return renderObj.runtimeType.toString() == 'RenderSuperSliverList';
+ },
);
Oh, my God. You're a genius. Thank you
Version
1.19.1
Platforms
Android
Device Model
Galaxy s9+
flutter info
How to reproduce?
observerController.jumpTo(index: 450);
The jumpTo function is too slow. It's like animateTo. In my case, My app has the ability to search for messages. Sometimes I have to go directly from index 0 to 1000. But the scrolling is too slow to get to the wanted index.
I want it to scroll to position immediately, such as scrollable_positioned_list or super_sliver_list. It's better to have alignment. Is it possible?
Thank you.
Logs
No response
Example code (optional)
Contact
No response