小编kik*_*kap的帖子

在导航中使用带有 GlobalKeys 的小部件

我的“主要”小部件必须具有全局键。如果我使用 apushNamed或等效项导航到它,它会生成关于小部件树中重复键的异常。我只能pop使用这个小部件,但这严重降低了我的导航选项和小部件的可重用性。

我已经包含了一个小型复制案例的来源,运行该应用程序,单击Login主页上的按钮,输入 3 个字符的登录名和 3 个字符的密码,然后Login.

有什么想法吗?在没有 的情况下重新设计GlobalKey是一项重大任务。

flutter: ??? EXCEPTION CAUGHT BY WIDGETS LIBRARY ????????????????????????????????????????????????????????????
flutter: The following assertion was thrown while finalizing the widget tree:
flutter: Duplicate GlobalKey detected in widget tree.
flutter: The following GlobalKey was specified multiple times in the widget tree. This will lead to parts of
flutter: the widget tree being truncated unexpectedly, because the second time a key is seen, the previous …
Run Code Online (Sandbox Code Playgroud)

flutter

5
推荐指数
1
解决办法
2357
查看次数

标签 统计

flutter ×1