auto_route_library
auto_route_library copied to clipboard
How to open Drawer programmatically in AutoTabsScaffold ?
How to open Drawer programmatically in AutoTabsScaffold ? like a Scaffold.of(context).openDrawer()
Any updates @ntfnd404 ? I'm trying to use both bottomNavigationBuilder
end drawer
is there any trick here?
AutoTabs scaffold wraps a Scaffold... Make sure you're calling Scaffold.of(comtext) with a context that has scaffold
AutoTabs scaffold wraps a Scaffold... Make sure you're calling Scaffold.of(comtext) with a context that has scaffold
Actually my case scenario is like this;
I've AutoTabsScaffold
and imagine in bottomNavigation I want to open drawer when nth item is tapped
What I've tried
In router.dart file
children: [
AutoRoute(..) // other bottomNavigation tabs
AutoRoute(
page: EmptyRouterPage,
name: 'DrawerTab',
path: RouterPath.drawer, // "drawer"
initial: true,
children: [
AutoRoute(
page: CalculatorScreen,
name: 'CalculatorScreen',
path: RouterPath.calculator,
)
]
)
]
//////
AutoTabsScaffold(
extendBody: true,
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
endDrawer: const EndDrawer(),
routes: const [
Tab1(),
Tab2(),
Tab3(),
Tab4(),
DrawerTab(),
],
bottomNavigationBuilder: (context, tabsRouter) =>
BottomBarApp(
onTabSelected: (index) {
switch (index) {
case 4:
Scaffold.of(context).openEndDrawer();
break;
default:
}
tabsRouter.setActiveIndex(index);
},
selectedIndex: tabsRouter.activeIndex,
color: const Color(0x47150C00),
selectedColor: Styleguide.primaryColor,
height: Dimension.bottomBarHeight,
items: [
...
],
),
),
So DrawerTab
here is actually a placeholder Route to contain pages (routes) exist in drawer,
Case1: If I select drawer tab, child routes is opened in Drawer and works as expected, but since DrawerTab's page is empty, when drawer (and it's related screens dismissed) is closed, there is empty page, so I need to actually stay in the bottom tab that I previously was before DrawerTab is selected.
Case2: If I do not set setActiveIndex
for tabsRouter to avoid problem happens in Case1, this time child routes can not be navigated in Drawer (because DrawerTab is not activated)
Sorry for long question, but you have any suggestion? @Milad-Akarie
AutoTabs scaffold wraps a Scaffold... Make sure you're calling Scaffold.of(comtext) with a context that has scaffold
@Milad-Akarie I'm sorry, I didn't put it correctly. How do I call '.openDrawer()' on AutoTabsScaffold which is in the root of the nested Scaffold. To open Drawer at the root one and not at the nested one
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions
AutoTabs scaffold wraps a Scaffold... Make sure you're calling Scaffold.of(comtext) with a context that has scaffold
@Milad-Akarie I'm sorry, I didn't put it correctly. How do I call '.openDrawer()' on AutoTabsScaffold which is in the root of the nested Scaffold. To open Drawer at the root one and not at the nested one
@ntfnd404 I know it is late but check this out: https://github.com/Milad-Akarie/auto_route_library/issues/982#issuecomment-1172888706
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions