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:

final formKey = GlobalKey<FormState>(); Form( key: formKey, child: TextFormField(), );

Comments

Popular posts from this blog

1. What is Flutter?

What is FutureBuilder and StreamBuilder?