We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7379550 commit c547101Copy full SHA for c547101
lib/services/router_service.dart
@@ -95,8 +95,15 @@ class NavigationManager {
95
static final GlobalKey<NavigatorState> settingsTabNavigatorKey =
96
GlobalKey<NavigatorState>();
97
98
- BuildContext get context =>
99
- router.routerDelegate.navigatorKey.currentContext!;
+ BuildContext get context {
+ final ctx = router.routerDelegate.navigatorKey.currentContext;
100
+ if (ctx == null) {
101
+ throw StateError(
102
+ 'NavigationManager.context was accessed before the navigator context was available.',
103
+ );
104
+ }
105
+ return ctx;
106
107
108
GoRouterDelegate get routerDelegate => router.routerDelegate;
109
0 commit comments