Flutter preserve scroll position of CustomScrollView inside hero

349 views Asked by At

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)?

0

There are 0 answers