I am working on the iPad and I have set up the screen to be SplitScreens
. Thus I have two Navigators
side by side. However, when I call to show a Snackbar
in one navigator with it's specific context, the Snackbar
is still showing on both navigators.
GlobalKey<NavigatorState> secondSplitNavigatorKey = GlobalKey<NavigatorState>();
GlobalKey<NavigatorState> firstSplitNavigatorKey = GlobalKey<NavigatorState>();
SplitView(
menu: Navigator(
key: firstSplitNavigatorKey,
onGenerateRoute: (routeSettings) {
return MaterialPageRoute(
builder: (context) =>
const KursplanungScreen(title: 'Demo App'),
);
},
),
content: Navigator(
key: secondSplitNavigatorKey,
onGenerateRoute: (routeSettings) {
return MaterialPageRoute(
builder: (context) => const Scaffold(
body: Center(
child: Text(
"Herzlich Willkommen!"))),
);
},
),
menuWidth: 300,
),
Later I call this in the second navigator:
ElevatedButton(
onPressed: () {
showSnackbar(
secondSplitNavigatorKey.currentState!.context,
"Bitte tragen Sie einen Fachnamen ein!");
},
child: const Icon(
Icons.add,
),
),
I only want the Snackbar to be showing in the second Navigator/Screen only!