0

I have a pane app with Drawer, which I show in a pane layout when the phone is in landscape mode:

enter image description here

To not animate the drawer between pages, I have put it into a Hero.

class SomePage extends Stateless Widget {
   Widget build(BuildContext context) {
    return Row(
       children: <Widget>[
         Hero(
           child: Material(
              elevation: 4.0,
              child: MyDrawer(),
              tag: "drawer",
           ),
           Expanded(
             child: Scaffold(
               appBar: ...,
               body: ...
             )
           ),
        ],
    );
  }
}

The drawer contains a CustomScrollView.

When the user changes pages using Navigator.pushNamed (I am using MaterialApp with onGenerateRoute), the scroll position of the CustomScrollView is reset.

How can I keep the scroll position between page changes (or how can I synchronize the scroll position of the drawer on different pages)?

Nathan
  • 7,099
  • 14
  • 61
  • 125
  • You have to share your code for us to understand your problem. How are you switching pages? Is it a PageView? Is it using the Navigator to a whole new view? – J. S. Mar 11 '20 at 14:35
  • Thanks for your comment. I tried to make the question more clearer. – Nathan Mar 11 '20 at 15:07
  • Unfortunately the code you wrote as an example doesn't shed light on how you are navigating from view to view. It's that that will define if your drawer is completely rebuild or not and cause your issue. – J. S. Mar 11 '20 at 15:15
  • I use the Navigator from MatieralApp and Navigator.pushNamed, I am actually unsure what else you want to see? My drawer is completely rebuild, yes! – Nathan Mar 11 '20 at 15:19
  • Why do you want your drawer to stay visible and maintain scroll position? That is not the standard behavior for a drawer. If you really want to do that, you may have to change how you are navigating in your app, or at least parts of it. – J. S. Mar 11 '20 at 15:22
  • Well, there are other examples with custom drawers. The iOS Settings app on an iPad is one. Also the material design guidelines (https://material.io/components/navigation-drawer/#bottom-drawer) mention an permanent navigation drawer. – Nathan Mar 11 '20 at 16:53
  • In the case of a permanent drawer, it's likely that the content is changing without rebuilding the whole view. You can do the same, but not navigating with your main Navigator. – J. S. Mar 11 '20 at 16:57

0 Answers0