Azamat Alimov
Azamat Alimov

Reputation: 21

How to change parentNavigatorKey dynamically

I have a responsive flutter app. For navigation i used bottom nav bar on mobile, sidemenu on desktop. On mobile most of details page should be without nav bar. For remove nav bar in this case i used parentNavigator key:

  GoRoute(
   parentNavigatorKey: _rootNavigatorKey,
   path: NotificationPage.path,
   builder: (BuildContext context, GoRouterState state) => const NotificationPage(),
   ),

But on desktop, side menu should be visible always. How can i do it.

I've tried with global nav key, but it doesnt work

                    parentNavigatorKey: _rootNavigatorKey.currentContext != null
                        ? MediaQuery.of(_rootNavigatorKey.currentContext!).size.width > 600
                            ? null
                            : _rootNavigatorKey
                        : _rootNavigatorKey,

Upvotes: 2

Views: 58

Answers (0)

Related Questions