easy_sidemenu
easy_sidemenu copied to clipboard
Sidebar doesn't show on initial route, but on homeroute.
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.
When use it as initial route any error or warning occurring?
no. i didnt see any errors in the web console or in the dart debug logs. That was the strange part.
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()))),
Is there an example somewhere of combining a Navigator and this easy_sidemenu widget?
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