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

ListView inside PageView should remember its scroll position when off-screen #8101

Closed
DavidMihola opened this issue Feb 13, 2017 · 17 comments
Closed
Assignees
Labels
customer: posse (eap) f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. waiting for PR to land (fixed) A fix is in flight

Comments

@DavidMihola
Copy link

This is just a question: In, for example, the "Stocks" example app, would it be possible to keep the scroll position from resetting every time I swipe left or right between the children of the TabBarView?

@abarth
Copy link
Contributor

abarth commented Feb 13, 2017

Yes, we need to fix this. The current thinking is to create a tree of scroll controllers somehow so that if you're in the middle of a vertical drag when you switch tabs, you'll be able to continue to drag vertically and the scroll will affect the new tab's contents.

/cc @Hixie

@abarth abarth changed the title Is there a way to save/restore the scroll position of TabBarView children? ListView inside PageView inside ListView should coordinate smoothly Feb 13, 2017
@DavidMihola
Copy link
Author

@abarth Thanks for the reply - just to be sure, in case my original question was poorly worded: What I meant was that if I (1) scroll down in Tab 1, then (2) swipe to Tab 2, then (3) swipe back to Tab 1, the ListView in Tab 1 will have lost it's scroll position and will have returned to the top of the list. (This is different from, e. g., an Android ViewPager, at least if the "offscreen page limit" is large enough, so that Tab 1 is not destroyed an re-created when swiping back and forth.)

Sorry, if that was what you meant anyway - in that case I just misunderstood your reply!

@abarth abarth changed the title ListView inside PageView inside ListView should coordinate smoothly ListView inside PageView should remember its scroll position when off-screen Feb 13, 2017
@abarth
Copy link
Contributor

abarth commented Feb 13, 2017

Ah, sorry. I misunderstood what you were asking for. I've updated the the bug title. Thanks!

@abarth abarth added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Feb 13, 2017
@DavidMihola
Copy link
Author

Perfect, thanks!

@Hixie
Copy link
Contributor

Hixie commented Feb 28, 2017

Yeah we should probably restore the page storage logic.

@abarth
Copy link
Contributor

abarth commented Mar 2, 2017

Bummer. I had code for that in #8074 but I don't see how to dig it out of the history of that PR.

@Hixie
Copy link
Contributor

Hixie commented Mar 3, 2017

Might still be in your reflog on your workstation?

@eseidelGoogle
Copy link
Contributor

eseidelGoogle commented Apr 4, 2017

@lukef can you help us understand the priority of this bug? It's not a hard fix, just not currently viewed as high severity.

@dmorawetz
Copy link

Hi, I have a similar question. My Pagelayout looks something like this:

  • PageView
    • Custom Widget
      • StreamBuilder
        • ListView constructed via ListView.builder

Now when I scroll down my ListView and then changed pages and come back exactly the thing @DavidMihola mentioned happens. It doesn't remember the index it was at. Is there any variable / reference I can pass down to the ListView, so it will remember where it was? I don't know, how you PR works internally, so I am very thankful, for any directions.

@yiailake
Copy link

@Morosko https://medium.com/@boldijar.paul/flutter-keeping-list-view-index-while-changing-page-view-c260352f35f8

@Josemboa
Copy link

Josemboa commented Nov 16, 2018

This helped me: https://stackoverflow.com/questions/46042537/multi-tab-page-view-in-flutter/46046510#46046510.

new ListView.builder( key: new PageStorageKey('yourkey'),

@Luppakorva
Copy link

Solution @Josemboa offered works great (thanks for that) but causes lots of lag if especially when you have lots of items in the list. I know this is an old discussion so perhaps there's a better way of doing it nowadays?

@cad0p
Copy link

cad0p commented Jan 2, 2020

Waiting as well! @Luppakorva @eseidelGoogle

@gguijarro-c-chwy
Copy link

gguijarro-c-chwy commented Mar 6, 2020

Any finds? @Luppakorva

@afnx
Copy link

afnx commented Apr 28, 2020

I would create the ListView in a StatefulWidget with AutomaticKeepAliveClientMixin and include bool get wantKeepAlive => true; in the state in order to stop re-rendering the list when switch between PageViews.

@checho040890
Copy link

Tengo un problema, en el body de mi scaffold género un Listview que llama a dos Swiper, y puedo hacer scroll sin problemas, el problema surge cuando agrego más, cuando hago scroll para volver al inicio de la página, este no llega nunca, se repiten los swiper..ayuda por favor

@lock
Copy link

lock bot commented May 21, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@lock lock bot locked and limited conversation to collaborators May 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer: posse (eap) f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. waiting for PR to land (fixed) A fix is in flight
Projects
None yet
Development

No branches or pull requests