Commit 930b52a3 authored by Adam Barth's avatar Adam Barth Committed by Adam Barth

Rename InputFormField to TextField

This patch is the first of a series to rationalize the names of the text-input
related widgets.

See #7031
parent 32fea4db
...@@ -205,7 +205,7 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> { ...@@ -205,7 +205,7 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> {
onCancel: () { Form.of(context).reset(); close(); }, onCancel: () { Form.of(context).reset(); close(); },
child: new Padding( child: new Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0), padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: new InputFormField( child: new TextField(
hintText: item.hint, hintText: item.hint,
labelText: item.name, labelText: item.name,
initialValue: new InputValue(text: item.value), initialValue: new InputValue(text: item.value),
......
...@@ -113,7 +113,7 @@ class TextFieldDemoState extends State<TextFieldDemo> { ...@@ -113,7 +113,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
child: new Block( child: new Block(
padding: const EdgeInsets.symmetric(horizontal: 16.0), padding: const EdgeInsets.symmetric(horizontal: 16.0),
children: <Widget>[ children: <Widget>[
// 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. // that builds an Input is equivalent.
new FormField<InputValue>( new FormField<InputValue>(
initialValue: InputValue.empty, initialValue: InputValue.empty,
...@@ -130,7 +130,7 @@ class TextFieldDemoState extends State<TextFieldDemo> { ...@@ -130,7 +130,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
); );
}, },
), ),
new InputFormField( new TextField(
icon: new Icon(Icons.phone), icon: new Icon(Icons.phone),
hintText: 'Where can we reach you?', hintText: 'Where can we reach you?',
labelText: 'Phone Number', labelText: 'Phone Number',
...@@ -138,7 +138,7 @@ class TextFieldDemoState extends State<TextFieldDemo> { ...@@ -138,7 +138,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
onSaved: (InputValue val) { person.phoneNumber = val.text; }, onSaved: (InputValue val) { person.phoneNumber = val.text; },
validator: _validatePhoneNumber, validator: _validatePhoneNumber,
), ),
new InputFormField( new TextField(
hintText: 'Tell us about yourself (optional)', hintText: 'Tell us about yourself (optional)',
labelText: 'Life story', labelText: 'Life story',
maxLines: 3, maxLines: 3,
...@@ -147,7 +147,7 @@ class TextFieldDemoState extends State<TextFieldDemo> { ...@@ -147,7 +147,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
new Expanded( new Expanded(
child: new InputFormField( child: new TextField(
key: _passwordFieldKey, key: _passwordFieldKey,
hintText: 'How do you log in?', hintText: 'How do you log in?',
labelText: 'New Password', labelText: 'New Password',
...@@ -157,7 +157,7 @@ class TextFieldDemoState extends State<TextFieldDemo> { ...@@ -157,7 +157,7 @@ class TextFieldDemoState extends State<TextFieldDemo> {
), ),
new SizedBox(width: 16.0), new SizedBox(width: 16.0),
new Expanded( new Expanded(
child: new InputFormField( child: new TextField(
hintText: 'How do you log in?', hintText: 'How do you log in?',
labelText: 'Re-type Password', labelText: 'Re-type Password',
hideText: true, hideText: true,
......
...@@ -386,7 +386,7 @@ class _InputContainerState extends State<InputContainer> { ...@@ -386,7 +386,7 @@ class _InputContainerState extends State<InputContainer> {
/// ///
/// Requires one of its ancestors to be a [Material] widget. /// 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 /// Assuming that the input is already focused, the basic data flow for
/// retrieving user input is: /// retrieving user input is:
...@@ -402,14 +402,14 @@ class _InputContainerState extends State<InputContainer> { ...@@ -402,14 +402,14 @@ class _InputContainerState extends State<InputContainer> {
/// See also: /// See also:
/// ///
/// * <https://material.google.com/components/text-fields.html> /// * <https://material.google.com/components/text-fields.html>
/// * [InputFormField], which simplifies steps 2-4 above. /// * [TextField], which simplifies steps 2-4 above.
class Input extends StatefulWidget { class Input extends StatefulWidget {
/// Creates a text input field. /// Creates a text input field.
/// ///
/// By default, the input uses a keyboard appropriate for text entry. /// By default, the input uses a keyboard appropriate for text entry.
// //
// If you change this constructor signature, please also update // If you change this constructor signature, please also update
// InputContainer, InputFormField, InputField. // InputContainer, TextField, InputField.
Input({ Input({
Key key, Key key,
this.value, this.value,
...@@ -553,10 +553,10 @@ class _InputState extends State<Input> { ...@@ -553,10 +553,10 @@ class _InputState extends State<Input> {
/// pass a [GlobalKey] to the constructor and use [GlobalKey.currentState] to /// pass a [GlobalKey] to the constructor and use [GlobalKey.currentState] to
/// save or reset the form field. /// 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. /// a simple two text field form.
/// ///
/// Using [InputFormField]: /// Using [TextField]:
/// ///
/// ```dart /// ```dart
/// String _firstName, _lastName; /// String _firstName, _lastName;
...@@ -566,11 +566,11 @@ class _InputState extends State<Input> { ...@@ -566,11 +566,11 @@ class _InputState extends State<Input> {
/// key: _formKey, /// key: _formKey,
/// child: new Row( /// child: new Row(
/// children: <Widget>[ /// children: <Widget>[
/// new InputFormField( /// new TextField(
/// labelText: 'First Name', /// labelText: 'First Name',
/// onSaved: (InputValue value) { _firstName = value.text; } /// onSaved: (InputValue value) { _firstName = value.text; }
/// ), /// ),
/// new InputFormField( /// new TextField(
/// labelText: 'Last Name', /// labelText: 'Last Name',
/// onSaved: (InputValue value) { _lastName = value.text; } /// onSaved: (InputValue value) { _lastName = value.text; }
/// ), /// ),
...@@ -613,8 +613,8 @@ class _InputState extends State<Input> { ...@@ -613,8 +613,8 @@ class _InputState extends State<Input> {
/// ), /// ),
/// ) /// )
/// ``` /// ```
class InputFormField extends FormField<InputValue> { class TextField extends FormField<InputValue> {
InputFormField({ TextField({
Key key, Key key,
GlobalKey focusKey, GlobalKey focusKey,
TextInputType keyboardType: TextInputType.text, TextInputType keyboardType: TextInputType.text,
......
...@@ -197,7 +197,10 @@ typedef Widget FormFieldBuilder<T>(FormFieldState<T> field); ...@@ -197,7 +197,10 @@ typedef Widget FormFieldBuilder<T>(FormFieldState<T> field);
/// pass a [GlobalKey] to the constructor and use [GlobalKey.currentState] to /// pass a [GlobalKey] to the constructor and use [GlobalKey.currentState] to
/// save or reset the form field. /// 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<T> extends StatefulWidget { class FormField<T> extends StatefulWidget {
FormField({ FormField({
Key key, Key key,
......
...@@ -46,7 +46,7 @@ class SampleForm extends StatelessWidget { ...@@ -46,7 +46,7 @@ class SampleForm extends StatelessWidget {
willPopCount += 1; willPopCount += 1;
return callback(); return callback();
}, },
child: new InputFormField(), child: new TextField(),
), ),
), ),
); );
......
...@@ -29,7 +29,7 @@ void main() { ...@@ -29,7 +29,7 @@ void main() {
child: new Material( child: new Material(
child: new Form( child: new Form(
key: formKey, key: formKey,
child: new InputFormField( child: new TextField(
onSaved: (InputValue value) { fieldValue = value.text; }, onSaved: (InputValue value) { fieldValue = value.text; },
), ),
) )
...@@ -61,7 +61,7 @@ void main() { ...@@ -61,7 +61,7 @@ void main() {
return new Center( return new Center(
child: new Material( child: new Material(
child: new Form( child: new Form(
child: new InputFormField( child: new TextField(
onChanged: (InputValue value) { fieldValue = value.text; }, onChanged: (InputValue value) { fieldValue = value.text; },
), ),
) )
...@@ -96,7 +96,7 @@ void main() { ...@@ -96,7 +96,7 @@ void main() {
child: new Form( child: new Form(
key: formKey, key: formKey,
autovalidate: autovalidate, autovalidate: autovalidate,
child: new InputFormField( child: new TextField(
key: inputKey, key: inputKey,
validator: errorText, validator: errorText,
), ),
...@@ -151,10 +151,10 @@ void main() { ...@@ -151,10 +151,10 @@ void main() {
key: focusKey, key: focusKey,
child: new Block( child: new Block(
children: <Widget>[ children: <Widget>[
new InputFormField( new TextField(
key: fieldKey key: fieldKey
), ),
new InputFormField( new TextField(
validator: errorText, validator: errorText,
), ),
] ]
...@@ -190,7 +190,7 @@ void main() { ...@@ -190,7 +190,7 @@ void main() {
return new Center( return new Center(
child: new Material( child: new Material(
child: new Form( child: new Form(
child: new InputFormField( child: new TextField(
key: inputKey, key: inputKey,
initialValue: new InputValue(text: initialValue), initialValue: new InputValue(text: initialValue),
), ),
...@@ -229,7 +229,7 @@ void main() { ...@@ -229,7 +229,7 @@ void main() {
child: new Material( child: new Material(
child: new Form( child: new Form(
key: formKey, key: formKey,
child: remove ? new Container() : new InputFormField( child: remove ? new Container() : new TextField(
key: fieldKey, key: fieldKey,
autofocus: true, autofocus: true,
onSaved: (InputValue value) { fieldValue = value.text; }, onSaved: (InputValue value) { fieldValue = value.text; },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment