flutter globalkey 的用法

文档写道,globalkey的作用是:

GlobalKeys have two uses:

a) they allow widgets to change parents (注意是parent , 怎么判断一个widget是不是另一个的parent ? )anywhere in your app without losing state,

or they can be used to access information about another widget in a completely different part of the widget tree. An example of the first scenario might if you wanted to show the same widget on two different screens, but holding all the same state, you’d want to use a GlobalKey. (不是parent似乎也可以)