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

[Bug report] jumpTo is too slow #79

Closed
IWantToKnowAboutThis opened this issue May 3, 2024 · 7 comments
Closed

[Bug report] jumpTo is too slow #79

IWantToKnowAboutThis opened this issue May 3, 2024 · 7 comments
Assignees

Comments

@IWantToKnowAboutThis
Copy link

Version

1.19.1

Platforms

Android

Device Model

Galaxy s9+

flutter info

• Engine revision e76c956498
    • Dart version 3.3.3
    • DevTools version 2.31.1

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at C:\Android\SDK                                             
    • Platform android-34, build-tools 34.0.0                                   
    • Java binary at: C:\Android\Studio\jbr\bin\java                     
    • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
    • All Android licenses accepted.                                     

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[!] Visual Studio - develop Windows apps (Visual Studio Community 2019 16.11.18)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.11.32802.440
    • Windows 10 SDK version 10.0.16299.0
    X Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop development with C++" workload, and include these components:
        MSVC v142 - VS 2019 C++ x64/x86 build tools
         - If there are multiple build tool versions available, install the latest
        C++ CMake tools for Windows
        Windows 10 SDK

[√] Android Studio (version 2023.2)
    • Android Studio at C:\Android\Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)

[√] Connected device (4 available)
    • SM G965F (mobile) • 1b9414152b027ece • android-arm64  • Android 13 (API 33)
    • Windows (desktop) • windows          • windows-x64    • Microsoft Windows [Version 10.0.19045.4291]
    • Chrome (web)      • chrome           • web-javascript • Google Chrome 124.0.6367.63
    • Edge (web)        • edge             • web-javascript • Microsoft Edge 124.0.2478.67

[√] Network resources
    • All expected network resources are available.

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)

observerController.jumpTo(index: 450);

Contact

No response

@LinXunFeng
Copy link
Member

LinXunFeng commented May 3, 2024

No, unless the height of your item is fixed.

observerController.jumpTo(index: 450, isFixedHeight: true); 

Releated issue: #5

@IWantToKnowAboutThis
Copy link
Author

My app is chat app. Of course, each item is different in height.

@IWantToKnowAboutThis
Copy link
Author

In the _handleScrollToIndex function, nextPageOffsetRectified is looking for it one by one, is there a way to go at once?

@LinXunFeng
Copy link
Member

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.

@IWantToKnowAboutThis
Copy link
Author

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.

@LinXunFeng
Copy link
Member

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';
+  },
);

@IWantToKnowAboutThis
Copy link
Author

IWantToKnowAboutThis commented May 3, 2024

Oh, my God. You're a genius. 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

2 participants