【发布时间】:2022-06-15 22:25:42
【问题描述】:
我正在使用 auto_route 包(编辑:AutoTabsRouter.tabBar)。 我有三个选项卡,其中一个选项卡有嵌套路由。我希望能够通过单击设置选项卡从 DetailsScreen 返回到 SettingsScreen。现在,我只能通过单击应用栏上的后退箭头来弹出。有办法吗?
AutoRoute(
page: MainPage,
children: [
AutoRoute(path: 'post', page: PostScreen),
AutoRoute(path: 'user', page: UserScreen),
AutoRoute(
path: 'settings',
name: 'SettingsRouter',
page: EmptyRouterPage,
children: [
AutoRoute(path: '', page: SettingsScreen),
AutoRoute(path: ':details', page: DetailsScreen),
RedirectRoute(path: '*', redirectTo: '')
],
),
],
initial: false,
),
【问题讨论】:
-
“现在,我只能通过点击应用栏上的返回箭头来弹出。有没有办法做到这一点?” - 是的,你需要致电
Navigator.of(context).pop() -
如果我使用 AutoTabsRouter.tabBar,我应该在哪里调用 navigator.of(context).pop()?
标签: flutter