From 50b7940b3081dbe7a0ff1e1745b5aff4cf635ca0 Mon Sep 17 00:00:00 2001 From: Remi Rousselet Date: Tue, 28 Jul 2020 18:26:14 +0100 Subject: [PATCH] Update the documentation of GlobalKey to explain why it is expensive (#62083) --- packages/flutter/lib/src/widgets/framework.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 1652a74891..2843f0568b 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -107,9 +107,13 @@ class ObjectKey extends LocalKey { /// in the same animation frame in which it was removed from its old location in /// the tree. /// -/// Global keys are relatively expensive. If you don't need any of the features -/// listed above, consider using a [Key], [ValueKey], [ObjectKey], or -/// [UniqueKey] instead. +/// Reparenting an [Element] using a global key is relatively expensive, as +/// this operation will trigger a call to [State.deactivate] on the associated +/// [State] and all of its descendants; then force all widgets that depends +/// on an [InheritedWidget] to rebuild. +/// +/// If you don't need any of the features listed above, consider using a [Key], +/// [ValueKey], [ObjectKey], or [UniqueKey] instead. /// /// You cannot simultaneously include two widgets in the tree with the same /// global key. Attempting to do so will assert at runtime.