From afe01503d8f5121313da5de1e17346c3e4a4fda2 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Thu, 21 Mar 2024 14:28:07 -0700 Subject: [PATCH] Clarify AutomaticKeepAliveClientMixin semantics in build method (#145297) This should help folks who trace the code before reading the documentation. --- packages/flutter/lib/src/widgets/automatic_keep_alive.dart | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/flutter/lib/src/widgets/automatic_keep_alive.dart b/packages/flutter/lib/src/widgets/automatic_keep_alive.dart index e5573db4a98..dd729d8cfc8 100644 --- a/packages/flutter/lib/src/widgets/automatic_keep_alive.dart +++ b/packages/flutter/lib/src/widgets/automatic_keep_alive.dart @@ -400,6 +400,10 @@ mixin AutomaticKeepAliveClientMixin on State { Widget build(BuildContext context) { if (wantKeepAlive && _keepAliveHandle == null) { _ensureKeepAlive(); + // Whenever wantKeepAlive's value changes (or might change), the + // subclass should call [updateKeepAlive]. + // That will ensure that the keepalive is disabled (or enabled) + // without requiring a rebuild. } return const _NullWidget(); }