防止对话框出现在稍后推送的页面上方

问题描述 投票:0回答:1

我在 flutter 中使用带有

go_router
的类型化路线。

我展示了这样的加载旋转器:

showDialog<void>(
  context: context,
  barrierDismissible: false,
  builder: (BuildContext context) {
    return const Dialog(
      backgroundColor: Colors.transparent,
      elevation: 0,
      child: Center(
        child: CircularProgressIndicator(
          valueColor: AlwaysStoppedAnimation<Color>(Colors.black),
        ),
      ),
    );
  },
);

然后我推送一个页面。

await goRouter.push(
  const RouteEditPage().location,
  extra: (
    ...
  ),
);

我希望新页面位于加载微调器上方。因为在这个页面中我添加了一些值并获取返回值或错误。页面关闭后,微调器应该仍会运行一段时间,直到某些进程完成。

目前加载对话框始终位于顶部。即使我稍后推送页面,对话框似乎位于堆栈的最顶层。

我该如何改变它?

flutter flutter-navigation flutter-go-router
1个回答
0
投票

当您想隐藏对话框时调用

Navigator.pop()
并在需要时再次显示对话框

© www.soinside.com 2019 - 2024. All rights reserved.