RafaelBarbosatec / hidden_drawer_menu

Hidden Drawer Menu is a library for adding a beautiful drawer mode menu feature with perspective animation.
MIT License
352 stars 55 forks source link

Keeping each ScreenHiddenDrawer alive? #21

Closed adar2378 closed 5 years ago

adar2378 commented 5 years ago

Each of the ScreenHiddenDrawer is rebuilding each time I change the the screen from the drawer. How can stop rebuilding it? Tried to include automatickeepalivemixin in each of the screens but not working!

elisar4 commented 5 years ago

Solved the issue by using IndexedStack like this:

return SimpleHiddenDrawer(
   menu: Menu(),
   screenSelectedBuilder: (position, controller) {
      return IndexedStack(
         index: position,
         children: <Widget>[
            HomePage(onPressed: () { controller.toggle(); }),
            MapPage(onPressed: () { controller.toggle(); }),
         ],
      );
   },
);

I think this concept is worth to be included in bundle of hidden_drawer_menu; For example as a parameter keepWidgetsAlive: bool, and if it is true - use IndexedStack behind the scene

RafaelBarbosatec commented 5 years ago

In the moment the soluction submited for @elisar4 looks good. I'm going to improve soon!