From 3e14f1817849a8bc7f2bb069115399648d533edf Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Fri, 10 May 2024 16:08:13 -0700 Subject: [PATCH] Docs on TextField disposed by a scrollable (#148149) Includes docs about the need to manually maintain a TextEditingController when using TextField in a ListView.builder (which was already documented on TextFormField). --- packages/flutter/lib/src/material/text_field.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/text_field.dart b/packages/flutter/lib/src/material/text_field.dart index 99822ef0fa..750495262b 100644 --- a/packages/flutter/lib/src/material/text_field.dart +++ b/packages/flutter/lib/src/material/text_field.dart @@ -126,10 +126,15 @@ class _TextFieldSelectionGestureDetectorBuilder extends TextSelectionGestureDete /// disposed. /// {@endtemplate} /// -/// Remember to call [TextEditingController.dispose] of the [TextEditingController] +/// Remember to call [TextEditingController.dispose] on the [TextEditingController] /// when it is no longer needed. This will ensure we discard any resources used /// by the object. /// +/// If this field is part of a scrolling container that lazily constructs its +/// children, like a [ListView] or a [CustomScrollView], then a [controller] +/// should be specified. The controller's lifetime should be managed by a +/// stateful widget ancestor of the scrolling container. +/// /// ## Obscured Input /// /// {@tool dartpad}