【问题标题】:Is there a way to pop to previous screen by clicking tab?有没有办法通过单击选项卡弹出到上一个屏幕?
【发布时间】:2022-06-15 22:25:42
【问题描述】:

我正在使用 auto_route 包(编辑:AutoTabsRouter.tabBar)。 我有三个选项卡,其中一个选项卡有嵌套路由。我希望能够通过单击设置选项卡从 DetailsS​​creen 返回到 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


猜你喜欢
  • 2011-10-03
  • 1970-01-01
  • 1970-01-01
  • 2021-06-17
  • 1970-01-01
  • 2023-02-16
  • 2020-08-22
  • 2015-10-16
  • 1970-01-01
相关资源
最近更新 更多