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
- GlobalKeys
Table of Contents
ValueKey:-
It is a regular key that uses simple Integer and string value.
ObjectKey:-
If you want to show more complex data rather than string or integer then you can use the Object key.
Unique key:-
This will provide your widget unique key every time. never put this key in the build method.
GlobalKey:-
The global key is used for maintaining state across the app because these are global variables
Further Reading: