From 930b52a3e5c395ec2e6394495533cfb684811c15 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Thu, 19 Jan 2017 12:55:10 -0800 Subject: [PATCH] Rename InputFormField to TextField This patch is the first of a series to rationalize the names of the text-input related widgets. See #7031 --- .../lib/demo/expansion_panels_demo.dart | 2 +- .../lib/demo/text_field_demo.dart | 10 +++++----- packages/flutter/lib/src/material/input.dart | 20 +++++++++---------- packages/flutter/lib/src/widgets/form.dart | 5 ++++- .../flutter/test/material/will_pop_test.dart | 2 +- packages/flutter/test/widgets/form_test.dart | 14 ++++++------- 6 files changed, 28 insertions(+), 25 deletions(-) diff --git a/examples/flutter_gallery/lib/demo/expansion_panels_demo.dart b/examples/flutter_gallery/lib/demo/expansion_panels_demo.dart index c106c1808e..29c18c968d 100644 --- a/examples/flutter_gallery/lib/demo/expansion_panels_demo.dart +++ b/examples/flutter_gallery/lib/demo/expansion_panels_demo.dart @@ -205,7 +205,7 @@ class _ExpansionPanelsDemoState extends State { onCancel: () { Form.of(context).reset(); close(); }, child: new Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: new InputFormField( + child: new TextField( hintText: item.hint, labelText: item.name, initialValue: new InputValue(text: item.value), diff --git a/examples/flutter_gallery/lib/demo/text_field_demo.dart b/examples/flutter_gallery/lib/demo/text_field_demo.dart index 8d5828f45a..bb86760947 100644 --- a/examples/flutter_gallery/lib/demo/text_field_demo.dart +++ b/examples/flutter_gallery/lib/demo/text_field_demo.dart @@ -113,7 +113,7 @@ class TextFieldDemoState extends State { child: new Block( padding: const EdgeInsets.symmetric(horizontal: 16.0), children: [ - // It's simpler to use an InputFormField, as below, but a FormField + // It's simpler to use an TextField, as below, but a FormField // that builds an Input is equivalent. new FormField( initialValue: InputValue.empty, @@ -130,7 +130,7 @@ class TextFieldDemoState extends State { ); }, ), - new InputFormField( + new TextField( icon: new Icon(Icons.phone), hintText: 'Where can we reach you?', labelText: 'Phone Number', @@ -138,7 +138,7 @@ class TextFieldDemoState extends State { onSaved: (InputValue val) { person.phoneNumber = val.text; }, validator: _validatePhoneNumber, ), - new InputFormField( + new TextField( hintText: 'Tell us about yourself (optional)', labelText: 'Life story', maxLines: 3, @@ -147,7 +147,7 @@ class TextFieldDemoState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ new Expanded( - child: new InputFormField( + child: new TextField( key: _passwordFieldKey, hintText: 'How do you log in?', labelText: 'New Password', @@ -157,7 +157,7 @@ class TextFieldDemoState extends State { ), new SizedBox(width: 16.0), new Expanded( - child: new InputFormField( + child: new TextField( hintText: 'How do you log in?', labelText: 'Re-type Password', hideText: true, diff --git a/packages/flutter/lib/src/material/input.dart b/packages/flutter/lib/src/material/input.dart index f926cf5249..f3865970cf 100644 --- a/packages/flutter/lib/src/material/input.dart +++ b/packages/flutter/lib/src/material/input.dart @@ -386,7 +386,7 @@ class _InputContainerState extends State { /// /// Requires one of its ancestors to be a [Material] widget. /// -/// When using inside a [Form], consider using [InputFormField] instead. +/// When using inside a [Form], consider using [TextField] instead. /// /// Assuming that the input is already focused, the basic data flow for /// retrieving user input is: @@ -402,14 +402,14 @@ class _InputContainerState extends State { /// See also: /// /// * -/// * [InputFormField], which simplifies steps 2-4 above. +/// * [TextField], which simplifies steps 2-4 above. class Input extends StatefulWidget { /// Creates a text input field. /// /// By default, the input uses a keyboard appropriate for text entry. // - // If you change this constructor signature, please also update - // InputContainer, InputFormField, InputField. + // If you change this constructor signature, please also update + // InputContainer, TextField, InputField. Input({ Key key, this.value, @@ -553,10 +553,10 @@ class _InputState extends State { /// pass a [GlobalKey] to the constructor and use [GlobalKey.currentState] to /// save or reset the form field. /// -/// To see the use of [InputFormField], compare these two ways of a implementing +/// To see the use of [TextField], compare these two ways of a implementing /// a simple two text field form. /// -/// Using [InputFormField]: +/// Using [TextField]: /// /// ```dart /// String _firstName, _lastName; @@ -566,11 +566,11 @@ class _InputState extends State { /// key: _formKey, /// child: new Row( /// children: [ -/// new InputFormField( +/// new TextField( /// labelText: 'First Name', /// onSaved: (InputValue value) { _firstName = value.text; } /// ), -/// new InputFormField( +/// new TextField( /// labelText: 'Last Name', /// onSaved: (InputValue value) { _lastName = value.text; } /// ), @@ -613,8 +613,8 @@ class _InputState extends State { /// ), /// ) /// ``` -class InputFormField extends FormField { - InputFormField({ +class TextField extends FormField { + TextField({ Key key, GlobalKey focusKey, TextInputType keyboardType: TextInputType.text, diff --git a/packages/flutter/lib/src/widgets/form.dart b/packages/flutter/lib/src/widgets/form.dart index 306c998bf1..b7f92c845c 100644 --- a/packages/flutter/lib/src/widgets/form.dart +++ b/packages/flutter/lib/src/widgets/form.dart @@ -197,7 +197,10 @@ typedef Widget FormFieldBuilder(FormFieldState field); /// pass a [GlobalKey] to the constructor and use [GlobalKey.currentState] to /// save or reset the form field. /// -/// See also: [Form], [InputFormField] +/// See also: +/// +/// * [Form], which is the widget that aggregates the form fields. +/// * [TextField], which is a commonly used form field for entering text. class FormField extends StatefulWidget { FormField({ Key key, diff --git a/packages/flutter/test/material/will_pop_test.dart b/packages/flutter/test/material/will_pop_test.dart index 3737365c20..14fb334f0d 100644 --- a/packages/flutter/test/material/will_pop_test.dart +++ b/packages/flutter/test/material/will_pop_test.dart @@ -46,7 +46,7 @@ class SampleForm extends StatelessWidget { willPopCount += 1; return callback(); }, - child: new InputFormField(), + child: new TextField(), ), ), ); diff --git a/packages/flutter/test/widgets/form_test.dart b/packages/flutter/test/widgets/form_test.dart index d1fea1e1ec..1ec131e550 100644 --- a/packages/flutter/test/widgets/form_test.dart +++ b/packages/flutter/test/widgets/form_test.dart @@ -29,7 +29,7 @@ void main() { child: new Material( child: new Form( key: formKey, - child: new InputFormField( + child: new TextField( onSaved: (InputValue value) { fieldValue = value.text; }, ), ) @@ -61,7 +61,7 @@ void main() { return new Center( child: new Material( child: new Form( - child: new InputFormField( + child: new TextField( onChanged: (InputValue value) { fieldValue = value.text; }, ), ) @@ -96,7 +96,7 @@ void main() { child: new Form( key: formKey, autovalidate: autovalidate, - child: new InputFormField( + child: new TextField( key: inputKey, validator: errorText, ), @@ -151,10 +151,10 @@ void main() { key: focusKey, child: new Block( children: [ - new InputFormField( + new TextField( key: fieldKey ), - new InputFormField( + new TextField( validator: errorText, ), ] @@ -190,7 +190,7 @@ void main() { return new Center( child: new Material( child: new Form( - child: new InputFormField( + child: new TextField( key: inputKey, initialValue: new InputValue(text: initialValue), ), @@ -229,7 +229,7 @@ void main() { child: new Material( child: new Form( key: formKey, - child: remove ? new Container() : new InputFormField( + child: remove ? new Container() : new TextField( key: fieldKey, autofocus: true, onSaved: (InputValue value) { fieldValue = value.text; },