Skip to content

Commit 5a92e2d

Browse files
committed
Improve dartdoc for GlobalKey
Fixes flutter#2708
1 parent dac1d4a commit 5a92e2d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

packages/flutter/lib/src/widgets/framework.dart

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,21 @@ class ObjectKey extends Key {
8484

8585
typedef void GlobalKeyRemoveListener(GlobalKey key);
8686

87-
/// A GlobalKey is one that must be unique across the entire application. It is
88-
/// used by widgets that need to communicate with other widgets across the
89-
/// application's element tree.
87+
/// A GlobalKey is a [Key] that must be unique across the widget tree.
88+
///
89+
/// Global keys uniquely indentify widget subtrees. The GlobalKey object provides
90+
/// access to other objects that are associated with the subtree, such as the subtree's
91+
/// [BuildContext] and, for [StatefulWidget]s, the subtree's [State].
92+
///
93+
/// Widgets that have global keys reparent their subtrees when they are moved
94+
/// from one location in the tree to another location in the tree. In order to
95+
/// reparent its subtree, a widget must arrive at its new location in the tree
96+
/// in the same animation frame in which it was removed from its old location in
97+
/// the tree.
98+
///
99+
/// GlobalKeys are relatively expensive. If you don't need any of the features
100+
/// listed above, consider using a [Key], [ValueKey], [ObjectKey], or
101+
/// [UniqueKey] instead.
90102
abstract class GlobalKey<T extends State<StatefulWidget>> extends Key {
91103
/// Constructs a LabeledGlobalKey, which is a GlobalKey with a label used for debugging.
92104
/// The label is not used for comparing the identity of the key.

0 commit comments

Comments
 (0)