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.
The error occurs in delegate.dart in class GoRouterDelegate. ↓
WillPopScope didn't work for me because the error was raised earlier.
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.