A material design text input field.
The value field must be updated each time the onChanged callback is invoked. Be sure to include the full value provided by the onChanged callback, or information like the current selection will be lost.
Requires one of its ancestors to be a Material widget.
When using inside a Form, consider using InputFormField instead.
Assuming that the input is already focused, the basic data flow for retrieving user input is:
- User taps a character on the keyboard.
- The onChanged callback is called with the current InputValue.
- Perform any necessary logic/validation on the current input value.
- Update the state of the Input widget accordingly through State.setState.
For most cases, we recommend that you use the Input class within a StatefulWidget so you can save and operate on the current value of the input.
See also:
- material.google.com/components/text-fields.html
- InputFormField, which simplifies steps 2-4 above.
- Inheritance
- Object
- Widget
- StatefulWidget
- Input
Constructors
- Input({Key key, InputValue value, TextInputType keyboardType: TextInputType.text, Widget icon, String labelText, String hintText, String errorText, TextStyle style, bool hideText: false, bool hideDivider: false, bool isDense: false, bool autofocus: false, int maxLines: 1, ValueChanged<InputValue> onChanged, ValueChanged<InputValue> onSubmitted })
-
Creates a text input field.
Properties
- autofocus → bool
-
Whether this input field should focus itself if nothing else is already focused. If true, the keyboard will open as soon as this input obtains focus. Otherwise, the keyboard is only shown after the user taps the text field.
read-only - errorText → String
-
Text to show when the input text is invalid.
read-only - hideDivider → bool
-
Hide the divider that appears below the child and above the error text.
read-only - hideText → bool
-
Whether to hide the text being edited (e.g., for passwords).
read-only - hintText → String
-
Text to show inline in the input field when it would otherwise be empty.
read-only - icon → Widget
-
An icon to show adjacent to the input field.
read-only - isDense → bool
-
Whether the input field is part of a dense form (i.e., uses less vertical space). If true, errorText is not shown.
read-only - keyboardType → TextInputType
-
The type of keyboard to use for editing the text.
read-only - labelText → String
-
Text to show above the input field.
read-only - maxLines → int
-
The maximum number of lines for the text to span, wrapping if necessary. If this is 1 (the default), the text will not wrap, but will scroll horizontally instead.
read-only - onChanged → ValueChanged<InputValue>
-
Called when the text being edited changes.
read-only - onSubmitted → ValueChanged<InputValue>
-
Called when the user indicates that they are done editing the text in the field.
read-only - style → TextStyle
-
The style to use for the text being edited.
read-only - value → InputValue
-
The current state of text of the input field. This includes the selected text, if any, among other things.
read-only - hashCode → int
-
Get a hash code for this object.
read-only, inherited - key → Key
-
Controls how one widget replaces another widget in the tree.
read-only, inherited - runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited
Methods
-
createState(
) → _InputState -
Creates the mutable state for this widget at a given location in the tree.
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited -
debugFillDescription(
List<String> description) → void -
Add additional information to the given description for use by toString.
inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited -
toString(
) → String -
Returns a string representation of this object.
inherited -
toStringShort(
) → String -
A short, textual description of this widget.
inherited