What are GlobalKeys and when to use them?
GlobalKey uniquely identifies widgets across the widget tree — useful to:
-
Access widget state from anywhere
-
Validate a form
-
Scroll to a widget
Example:
GlobalKey uniquely identifies widgets across the widget tree — useful to:
Access widget state from anywhere
Validate a form
Scroll to a widget
Example:
final formKey = GlobalKey<FormState>(); Form( key: formKey, child: TextFormField(), );
Comments
Post a Comment