0

In my application I have ShellRoute, which I use for BottomNavigation. If I use the system back button or gesture on the selected tab, I get a null safety error and I don't know how to get rid of it.

enter image description here enter image description here

The error occurs in delegate.dart in class GoRouterDelegate. ↓

enter image description here

WillPopScope didn't work for me because the error was raised earlier.

Zelkreps
  • 11
  • 3

1 Answers1

0

The solution to my question was to redo the bottom navigation as shown here in example:

https://github.com/flutter/packages/blob/main/packages/go_router/example/lib/shell_route.dart

   ShellRoute(
    navigatorKey: _shellNavigatorKey,
    builder: (BuildContext context, GoRouterState state, Widget child) {
      return ScaffoldWithNavBar(child: child);
    },
   ....

It is necessary to pass a child inside the ShellRoute, it is not enough to solve it inside otherwise the context is not passed.

Zelkreps
  • 11
  • 3