From 23174c34b14dbefd92776aa21d95f1e7f8e9f3d0 Mon Sep 17 00:00:00 2001 From: Rubens de Melo Date: Thu, 6 Jun 2019 14:41:48 -0300 Subject: [PATCH] Include advice about dispose in TextEditingController api (#33653) * include advice about dispose The same note in https://flutter.dev/docs/cookbook/forms/text-field-changes * Include remember to dispose texteditingcontroller Almost the same note here https://flutter.dev/docs/cookbook/forms/text-field-changes#2-use-a-texteditingcontroller . * include remember to dispose TextEditingController and link to see also * remove extras spaces and duplicated comment * include details about using Positioned.fill * Revert "include details about using Positioned.fill" This reverts commit c06196f8884d20c547d97edae71d26f7a61701be. * rever comment about Positioned.fill * Include of and remove extra white space Include of and remove extra white space in the end of line * improve link description to cookbook /// * Learn how to use a [TextEditingController] in one of our [cookbook recipe]s.(https://flutter.dev/docs/cookbook/forms/text-field-changes#2-use-a-texteditingcontroller) * include of, remove extra white space and improve description link to cookbook. include of, remove extra white space and improve description link to cookbook. * include of, remove extra white space and improve link description to cookbook include of, remove extra white space and improve link description to cookbook * include of, remove extra white space and improve link description to cookbook include of, remove extra white space and improve link description to cookbook * remove extra white spaces * remove extra white space --- packages/flutter/lib/src/cupertino/text_field.dart | 4 ++++ packages/flutter/lib/src/material/text_field.dart | 4 ++++ packages/flutter/lib/src/material/text_form_field.dart | 4 ++++ packages/flutter/lib/src/widgets/editable_text.dart | 3 +++ 4 files changed, 15 insertions(+) diff --git a/packages/flutter/lib/src/cupertino/text_field.dart b/packages/flutter/lib/src/cupertino/text_field.dart index 85e0dd1357..692c8e7a31 100644 --- a/packages/flutter/lib/src/cupertino/text_field.dart +++ b/packages/flutter/lib/src/cupertino/text_field.dart @@ -117,6 +117,9 @@ enum OverlayVisibilityMode { /// rounded rectangle border around the text field. If you set the [decoration] /// property to null, the decoration will be removed entirely. /// +/// Remember to [dispose] of the [TextEditingController] when it is no longer needed. +/// This will ensure we discard any resources used by the object. +/// /// See also: /// /// * @@ -124,6 +127,7 @@ enum OverlayVisibilityMode { /// Design UI conventions. /// * [EditableText], which is the raw text editing control at the heart of a /// [TextField]. +/// * Learn how to use a [TextEditingController] in one of our [cookbook recipe]s.(https://flutter.dev/docs/cookbook/forms/text-field-changes#2-use-a-texteditingcontroller) class CupertinoTextField extends StatefulWidget { /// Creates an iOS-style text field. /// diff --git a/packages/flutter/lib/src/material/text_field.dart b/packages/flutter/lib/src/material/text_field.dart index 1d8aef085f..e094ebc875 100644 --- a/packages/flutter/lib/src/material/text_field.dart +++ b/packages/flutter/lib/src/material/text_field.dart @@ -65,6 +65,9 @@ typedef InputCounterWidgetBuilder = Widget Function( /// To integrate the [TextField] into a [Form] with other [FormField] widgets, /// consider using [TextFormField]. /// +/// Remember to [dispose] of the [TextEditingController] when it is no longer needed. +/// This will ensure we discard any resources used by the object. +/// /// {@tool sample} /// This example shows how to create a [TextField] that will obscure input. The /// [InputDecoration] surrounds the field in a border using [OutlineInputBorder] @@ -91,6 +94,7 @@ typedef InputCounterWidgetBuilder = Widget Function( /// [TextField]. The [EditableText] widget is rarely used directly unless /// you are implementing an entirely different design language, such as /// Cupertino. +/// * Learn how to use a [TextEditingController] in one of our [cookbook recipe]s.(https://flutter.dev/docs/cookbook/forms/text-field-changes#2-use-a-texteditingcontroller) class TextField extends StatefulWidget { /// Creates a Material Design text field. /// diff --git a/packages/flutter/lib/src/material/text_form_field.dart b/packages/flutter/lib/src/material/text_form_field.dart index 25b886bddb..f111b77a5d 100644 --- a/packages/flutter/lib/src/material/text_form_field.dart +++ b/packages/flutter/lib/src/material/text_form_field.dart @@ -29,6 +29,9 @@ import 'theme.dart'; /// If a [controller] is not specified, [initialValue] can be used to give /// the automatically generated controller an initial value. /// +/// Remember to [dispose] of the [TextEditingController] when it is no longer needed. +/// This will ensure we discard any resources used by the object. +/// /// For a documentation about the various parameters, see [TextField]. /// /// {@tool sample} @@ -60,6 +63,7 @@ import 'theme.dart'; /// integration. /// * [InputDecorator], which shows the labels and other visual elements that /// surround the actual text editing widget. +/// * Learn how to use a [TextEditingController] in one of our [cookbook recipe]s.(https://flutter.dev/docs/cookbook/forms/text-field-changes#2-use-a-texteditingcontroller) class TextFormField extends FormField { /// Creates a [FormField] that contains a [TextField]. /// diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index d1cf8af57d..da64e7503d 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -67,6 +67,8 @@ const int _kObscureShowLatestCharCursorTicks = 3; /// added to this controller. If both properties need to be changed then the /// controller's [value] should be set instead. /// +/// Remember to [dispose] of the [TextEditingController] when it is no longer needed. +/// This will ensure we discard any resources used by the object. /// {@tool snippet --template=stateful_widget_material} /// This example creates a [TextField] with a [TextEditingController] whose /// change listener forces the entered text to be lower case and keeps the @@ -113,6 +115,7 @@ const int _kObscureShowLatestCharCursorTicks = 3; /// with a [TextEditingController]. /// * [EditableText], which is a raw region of editable text that can be /// controlled with a [TextEditingController]. +/// * Learn how to use a [TextEditingController] in one of our [cookbook recipe]s.(https://flutter.dev/docs/cookbook/forms/text-field-changes#2-use-a-texteditingcontroller) class TextEditingController extends ValueNotifier { /// Creates a controller for an editable text field. ///