How to Use `GlobalKey` to Maintain Widgets' States When Changing Parents

How to Use GlobalKey to Maintain Widgets States When Changing Parents?

· 8 min read

GlobalKeys have two uses: they allow widgets to change parents 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…