Skip to content

Documentation of Usage of Input Widget#277

Merged
sethladd merged 10 commits intoflutter:masterfrom
dvdwasibi:input_documentation
Sep 26, 2016
Merged

Documentation of Usage of Input Widget#277
sethladd merged 10 commits intoflutter:masterfrom
dvdwasibi:input_documentation

Conversation

@dvdwasibi
Copy link
Copy Markdown

@dvdwasibi dvdwasibi commented Sep 23, 2016

@sethladd

Adding richer documentation and examples of using the Input widget.

For issue #5987

Comment thread text-input.md Outdated

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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please line break this. makes review a lot easier.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread text-input.md Outdated
Using the Input Widget
---------

Assuming that the input is already in focus, the basic data flow for retrieving user input will be:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

global: line break at 80

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread text-input.md Outdated
Example
---------

This example is a `StatefulWidget` that mirrors the text inside an `Input`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space after this line, before the code sample

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@dvdwasibi
Copy link
Copy Markdown
Author

dvdwasibi commented Sep 23, 2016

@sethladd Pushed new changes and fixed the merge issue.

Comment thread text-input.md Outdated

## Introduction

This page describe how to setup basic text input for Flutter applications.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's setup or "set up". cc @qchong

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"set up" is correct.

Comment thread text-input.md Outdated
[`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
Copy link
Copy Markdown
Contributor

@sethladd sethladd Sep 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/will probably satisfy/satisfies

s/text-input/text input

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread text-input.md Outdated
[`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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Input widget implements material design's style. If you want an input widget that does not use material design, see RawInputLine.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread text-input.md Outdated
to achieve desired interfaces outside of the Material Design language.


Using the Input Widget
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer prefixing headers with # or ## (depending on your needs). That way, you don't need to match the length of ----

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread text-input.md Outdated
to achieve desired interfaces outside of the Material Design language.


Using the Input Widget
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread text-input.md Outdated
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/you will probably want/we recommend

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Comment thread text-input.md Outdated
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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/since you want to/so you can

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread text-input.md Outdated
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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a word after "save the" ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread text-input.md Outdated
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please read our guide on managing widget state.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread text-input.md Outdated
you should look at the
[managing state guide](https://flutter.io/widgets-intro/#managing-state) first.

Example
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use # or ##

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@sethladd
Copy link
Copy Markdown
Contributor

Thanks @dvdwasibi ! Much appreciated.

@qchong might also want to provide a review.

@dvdwasibi
Copy link
Copy Markdown
Author

@sethladd Pushed up the new fixes in 5ec6c4c

Copy link
Copy Markdown
Contributor

@sethladd sethladd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! lgtm after these tweaks but @qchong should also review :)

Comment thread text-input.md Outdated

## Introduction

This page describe how to set up basic text input for Flutter applications.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/describe/describes

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

Comment thread text-input.md Outdated
[`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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, now I think it should be ", and implements material design's style".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

Comment thread text-input.md Outdated
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
Copy link
Copy Markdown
Contributor

@sethladd sethladd Sep 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end sentences with a period. (global. See also #3 in this list)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

Comment thread text-input.md Outdated
[`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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You used "value" before, but you use the word "state" here. Does an input have a value or a state?

Copy link
Copy Markdown
Author

@dvdwasibi dvdwasibi Sep 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has a value. Fixed.

Comment thread text-input.md Outdated

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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drop "the", so it reads "with StatefulWidget".

s/managing.../how to manage state in Flutter

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

Copy link
Copy Markdown
Contributor

@sethladd sethladd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with one comment

Over to @qchong !

Comment thread text-input.md Outdated

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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Copy Markdown
Contributor

@sethladd sethladd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

output: web

- title: Text Input
url: /text-input/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a link on the index.md page as well.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

Comment thread text-input.md Outdated
[`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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Also added links for all API class references.

Comment thread text-input.md Outdated
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest rewriting to something like this: "...we recommend that you add the Input class..."

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. I changed it to "...we recommend that you use the Input class..."

Copy link
Copy Markdown
Contributor

@qchong qchong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, overall looks good. I've added some comments for a few stylistic improvements. Thanks for working on this!

@sethladd sethladd merged commit 6c88aa6 into flutter:master Sep 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants