[英]Flutter: go_router 6.0.1 KEYCODE_BACK throw null safety error in ShellRoute
In my application I have ShellRoute, which I use for BottomNavigation.在我的应用程序中,我有 ShellRoute,我将其用于 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.
如果我在所选选项卡上使用系统后退按钮或手势,我会收到 null 安全错误,我不知道如何摆脱它。
The error occurs in delegate.dart in class GoRouterDelegate.错误出现在class GoRouterDelegate中的delegate.dart。 ↓
↓
WillPopScope didn't work for me because the error was raised earlier. WillPopScope 对我不起作用,因为错误是较早出现的。
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 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.需要在ShellRoute内部传一个child,在里面解决不行否则传不上context。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.