csells / go_router

The purpose of the go_router for Flutter is to use declarative routes to reduce complexity, regardless of the platform you're targeting (mobile, web, desktop), handling deep linking from Android, iOS and the web while still allowing an easy-to-use developer experience.
https://gorouter.dev
442 stars 96 forks source link

Scroll position is reset when returning from navigation #45

Closed doughywilson closed 2 years ago

doughywilson commented 2 years ago

I have a tab screen using AutomaticKeepAliveClientMixin that has a listview of many items. When a user clicks one of those items, I do a pushNamed() to get to the detail view of that item, and the appbar provides the back button to pop the navigation stack. When the navigation stack gets popped back to the original listview tab, the scroll position goes back to the top.

I do no this issue when using the traditional router. Only with go_router.

This issue might be related to #44 .

Thanks!

csells commented 2 years ago

Is your page stateful or stateless? It should work if it's stateful.

doughywilson commented 2 years ago

The page is stateful and all other state is kept, it's just that the scrolling doesn't stay put. This could be solvable by implementing your strategy for redirects though. I'm thinking it could be the way I am checking auth state in my app is getting in the way of the new routing paradigm.

csells commented 2 years ago

Can you post a minimal repro sample?

doughywilson commented 2 years ago

Before I send you or anyone else down that rabbit hole, I want to try implementing the redirect function for checking auth in my app. I think this could be causing my widgets to rebuild in the flow of the new routing. I have run into another issue with the redirect function, so I need to solve that before I'll know if this issue is relevant to my application or go_router.

rydmike commented 2 years ago

This PR https://github.com/csells/go_router/pull/56 updates the example nested_nav.dart to demonstrate it with the FamilyView tab content screen(s) and also shows that it works in the example case.