【问题标题】:ERROR: Duplicate GlobalKey detected in widget tree错误:在小部件树中检测到重复的 GlobalKey
【发布时间】:2021-06-25 16:00:47
【问题描述】:

当我将其作为我开发的应用程序中的注销部分再次发送到登录屏幕时,我收到此错误。

在小部件树中检测到重复的 GlobalKey。

我的注销方法如下。我需要处理全局密钥吗?你能帮帮我吗?

Navigator.of(context).push(
                MaterialPageRoute(builder: (BuildContext context) => Yoklama()),
              );

【问题讨论】:

    标签: flutter dart flutter-navigation


    【解决方案1】:

    也许你应该试试这个

    Navigator.pop(context);
    

    发生这种情况是因为您的登录屏幕没有关闭,并且您在单击注销时尝试重新打开它。

    如果上面的代码对你不起作用,那么试试这个。

    当您登录后使用此导航器:

      Navigator.of(context).pushReplacement(
              MaterialPageRoute(builder: (BuildContext context) => YourHomePageScreen()),
            );
    

    当你注销时使用这个

    Navigator.of(context).pushReplacement(
                    MaterialPageRoute(builder: (BuildContext context) => Yoklama()),
                  );
    

    【讨论】:

      猜你喜欢
      • 2018-08-28
      • 2020-04-14
      • 2021-05-17
      • 2019-04-28
      • 2021-07-30
      • 2021-09-01
      • 2022-08-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多