Documentation of Usage of Input Widget#277
Conversation
|
|
||
| This page describe how to setup basic text input for Flutter applications. | ||
|
|
||
| The [`Input`](https://docs.flutter.io/flutter/material/Input-class.html) widget under [Material](https://docs.flutter.io/flutter/material/material-library.html) will probably satisfy most text-input use cases. However, `Input` is coupled with the Material Design style so there might be cases where you want to use [`RawInputLine`](https://docs.flutter.io/flutter/widgets/RawInputLine-class.html) to achieve desired interfaces outside of the Material Design language. |
There was a problem hiding this comment.
please line break this. makes review a lot easier.
| Using the Input Widget | ||
| --------- | ||
|
|
||
| Assuming that the input is already in focus, the basic data flow for retrieving user input will be: |
| Example | ||
| --------- | ||
|
|
||
| This example is a `StatefulWidget` that mirrors the text inside an `Input`. |
There was a problem hiding this comment.
nit: space after this line, before the code sample
|
@sethladd Pushed new changes and fixed the merge issue. |
|
|
||
| ## Introduction | ||
|
|
||
| This page describe how to setup basic text input for Flutter applications. |
There was a problem hiding this comment.
Seems like it should be "set up":
https://www.visualthesaurus.com/cm/wc/is-it-set-up-set-up-or-setup/
Fixed.
| [`Input`](https://docs.flutter.io/flutter/material/Input-class.html) | ||
| widget under | ||
| [Material](https://docs.flutter.io/flutter/material/material-library.html ) | ||
| will probably satisfy most text-input use cases. However, `Input` is coupled |
There was a problem hiding this comment.
s/will probably satisfy/satisfies
s/text-input/text input
| [`Input`](https://docs.flutter.io/flutter/material/Input-class.html) | ||
| widget under | ||
| [Material](https://docs.flutter.io/flutter/material/material-library.html ) | ||
| will probably satisfy most text-input use cases. However, `Input` is coupled |
There was a problem hiding this comment.
The Input widget implements material design's style. If you want an input widget that does not use material design, see RawInputLine.
| to achieve desired interfaces outside of the Material Design language. | ||
|
|
||
|
|
||
| Using the Input Widget |
There was a problem hiding this comment.
I prefer prefixing headers with # or ## (depending on your needs). That way, you don't need to match the length of ----
| to achieve desired interfaces outside of the Material Design language. | ||
|
|
||
|
|
||
| Using the Input Widget |
There was a problem hiding this comment.
I like to use headers that are descriptive of solving a user problem.
The user problem isn't "I need to use an Input Widget", it's (in this case), "Retrieving user input".
| 3. Perform any necessary logic/validation on the current input value | ||
| 4. Update the `Input` widget accordingly. | ||
|
|
||
| For most cases, you will probably want to use a `Input` within a [`StatefulWidget`](https://docs.flutter.io/flutter/widgets/StatefulWidget-class.html) |
There was a problem hiding this comment.
s/you will probably want/we recommend
| 4. Update the `Input` widget accordingly. | ||
|
|
||
| For most cases, you will probably want to use a `Input` within a [`StatefulWidget`](https://docs.flutter.io/flutter/widgets/StatefulWidget-class.html) | ||
| since you want to save the and operate on the current state of the input. |
There was a problem hiding this comment.
s/since you want to/so you can
| 4. Update the `Input` widget accordingly. | ||
|
|
||
| For most cases, you will probably want to use a `Input` within a [`StatefulWidget`](https://docs.flutter.io/flutter/widgets/StatefulWidget-class.html) | ||
| since you want to save the and operate on the current state of the input. |
There was a problem hiding this comment.
missing a word after "save the" ?
| For most cases, you will probably want to use a `Input` within a [`StatefulWidget`](https://docs.flutter.io/flutter/widgets/StatefulWidget-class.html) | ||
| since you want to save the and operate on the current state of the input. | ||
| If you are unfamiliar with the `StatefulWidget` and managing state in Flutter, | ||
| you should look at the |
There was a problem hiding this comment.
please read our guide on managing widget state.
| you should look at the | ||
| [managing state guide](https://flutter.io/widgets-intro/#managing-state) first. | ||
|
|
||
| Example |
|
Thanks @dvdwasibi ! Much appreciated. @qchong might also want to provide a review. |
|
|
||
| ## Introduction | ||
|
|
||
| This page describe how to set up basic text input for Flutter applications. |
| [`Input`](https://docs.flutter.io/flutter/material/Input-class.html) | ||
| widget under | ||
| [Material](https://docs.flutter.io/flutter/material/material-library.html ) | ||
| satisfies most text input use cases. The `Input` widget implements material |
There was a problem hiding this comment.
hm, now I think it should be ", and implements material design's style".
| 1. User taps a character in the keyboard. | ||
| 2. The | ||
| [`OnChanged`](https://docs.flutter.io/flutter/material/Input/onChanged.html) | ||
| callback is called with the current `value` of the widget |
There was a problem hiding this comment.
end sentences with a period. (global. See also #3 in this list)
| [`setState()`](https://docs.flutter.io/flutter/widgets/State/setState.html). | ||
|
|
||
| For most cases, we recommend a `Input` within a [`StatefulWidget`](https://docs.flutter.io/flutter/widgets/StatefulWidget-class.html) | ||
| so you can save and operate on the current state of the input. |
There was a problem hiding this comment.
You used "value" before, but you use the word "state" here. Does an input have a value or a state?
|
|
||
| For most cases, we recommend a `Input` within a [`StatefulWidget`](https://docs.flutter.io/flutter/widgets/StatefulWidget-class.html) | ||
| so you can save and operate on the current state of the input. | ||
| If you are unfamiliar with the `StatefulWidget` and managing state in Flutter, |
There was a problem hiding this comment.
drop "the", so it reads "with StatefulWidget".
s/managing.../how to manage state in Flutter
|
|
||
| For most cases, we recommend a `Input` within a [`StatefulWidget`](https://docs.flutter.io/flutter/widgets/StatefulWidget-class.html) | ||
| so you can save and operate on the current value of the input. | ||
| If you are unfamiliar with `StatefulWidget` and managing state in Flutter, |
There was a problem hiding this comment.
Actually, this might be better as "To learn more about StatefulWidget and managing state in Flutter, ..."
(avoiding the conditional and the negative at the start of the sentence :)
| output: web | ||
|
|
||
| - title: Text Input | ||
| url: /text-input/ |
There was a problem hiding this comment.
Please create a link on the index.md page as well.
| [`OnChanged`](https://docs.flutter.io/flutter/material/Input/onChanged.html) | ||
| callback is called with the current `value` of the widget. | ||
| 3. Perform any necessary logic/validation on the current input value. | ||
| 4. Update the state of the `Input` widget accordingly through |
There was a problem hiding this comment.
For consistency, please create a link to the Input class API reference whenever you refer to the Input widget. Please make this change to all instances on this page.
There was a problem hiding this comment.
Fixed. Also added links for all API class references.
| 4. Update the state of the `Input` widget accordingly through | ||
| [`setState()`](https://docs.flutter.io/flutter/widgets/State/setState.html). | ||
|
|
||
| For most cases, we recommend a `Input` within a [`StatefulWidget`](https://docs.flutter.io/flutter/widgets/StatefulWidget-class.html) |
There was a problem hiding this comment.
Suggest rewriting to something like this: "...we recommend that you add the Input class..."
There was a problem hiding this comment.
Fixed. I changed it to "...we recommend that you use the Input class..."
qchong
left a comment
There was a problem hiding this comment.
lgtm, overall looks good. I've added some comments for a few stylistic improvements. Thanks for working on this!
@sethladd
Adding richer documentation and examples of using the
Inputwidget.For issue #5987