easy_sidemenu icon indicating copy to clipboard operation
easy_sidemenu copied to clipboard

Sidebar doesn't show on initial route, but on homeroute.

Open anovis opened this issue 2 years ago • 5 comments

I am using MaterialApp for my flutter web project and for some reason the sidebar is not being rendered at all when the widget is set as an initial route, but it works correctly when it is set as the home route.

MaterialApp(
                title: 'project',
           
                onGenerateRoute: generateRoutes,
              
                initialRoute: YRoutes.WebHome,
                home: WebHome());

YRoutes.WebHome points to Webhome()`

MaterialPageRoute(
          settings: settings, builder: (BuildContext context) => WebHome())

curious why this might be the case.

anovis avatar Nov 14 '22 03:11 anovis

When use it as initial route any error or warning occurring?

Jamalianpour avatar Nov 14 '22 05:11 Jamalianpour

no. i didnt see any errors in the web console or in the dart debug logs. That was the strange part.

anovis avatar Nov 15 '22 02:11 anovis

This happens also when hot restart the app. After restating the app will be just like navigator pushed to the first widget instead of showing menu with the widgets.

Edit: the issue disappears when the route from material app is removed and just use pushReplacement just like this

Navigator.pushReplacement(context, MaterialPageRoute(builder: ((context) => Screen2()))),

thivankasarathchandra avatar Jan 17 '23 05:01 thivankasarathchandra

Is there an example somewhere of combining a Navigator and this easy_sidemenu widget?

SteveBraich avatar Jun 27 '23 20:06 SteveBraich

       Replace the _widthSize function with this code snippet:

   double _widthSize(SideMenuDisplayMode mode, BuildContext context) {
    if (mode == SideMenuDisplayMode.open) {
      Global.displayModeState.change(SideMenuDisplayMode.open);
      Future.delayed(_toggleDuration(), () {
       Global.showTrailing = true;
         for (var update in Global.itemsUpdate) {
           update();
         }
         });
         _notifyParent();
          return 250;
        }
      if (mode == SideMenuDisplayMode.compact) {
      if (Global.displayModeState.value != SideMenuDisplayMode.compact) {
        Global.displayModeState.change(SideMenuDisplayMode.compact);
        _notifyParent();
         Global.showTrailing = false;
       }
       return 66;
    }
    return 250;
   }

We can change the value 250 and 66 as we need

And, from SideMenuStyle(), set displayMode: SideMenuDisplayMode.open

I got this solution on StackOverFlow and applied the same, that works for me. Please fix it in the library. This library is really awesome. Thank You

mdfaizanwar avatar Sep 18 '23 18:09 mdfaizanwar