我的“主要”小部件必须具有全局键。如果我使用 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 ×1