keys are very less used in the flutter framework , it works when the widget moves around in the widget tree. According to the documentation
A Key is an identifier for Widgets, Elements and SemanticsNodes. A key that uses a value of a particular type to identify itself.
There are 4 types of keys that exist in Flutter
- Value Key
- Object Key
- Unique Key
It is a regular key that uses simple Integer and string value.
If you want to show more complex data rather than string or integer then you can use the Object key.
This will provide your widget unique key every time. never put this key in the build method.
The global key is used for maintaining state across the app because these are global variables