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

document go_router + AutomaticKeepAliveClientMixin to keep ListView scroll position #44

Closed csells closed 2 years ago

csells commented 2 years ago

Shawn: "If you stick an AutomaticKeepAliveClientMixin on any of the top-level tabs, then they retain their state between tabs and you get the full "nested navigation + persistent tabs" that many folks are looking for. Just had to make FamilyView stateful, and add that mixin to the state, and the ListView remembers it's scroll position between routes! The entire widget state is retained. Like I can add a counter btn to each view, or a textfield, totally retains state between tabs."

rydmike commented 2 years ago

This PR #56 updates the example nested_nav.dart to demonstrate it with the FamilyView tab content screen(s). The usage is described in example comments, but may still need a mention in the readme.

It is a good idea to add this to the example, as the usage of the AutomaticKeepAliveClientMixin is not necessarily so well known among Flutter developers. It would of course be easier to try it and see that it works, if there was more scrollable content on the example screens, but in a Web build it can be tested by resizing the browser window to see it.

csells commented 2 years ago

fixed in v2.0.0.