FormTextField<TValue> class

Widgets for text fields for forms.

Place under the Form that gave FormController.key, or pass FormController to form.

When FormController is passed to form, onSaved must also be passed together. The contents of onSaved will be used to save the data.

Enter the initial value given by FormController.value in initialValue.

Each time the content is changed, onChanged is executed.

When FormController.validate is executed, validation and data saving are performed.

Only when emptyErrorText is specified, emptyErrorText will be displayed as an error if no characters are entered. Only when lengthErrorText is specified, if the number of characters entered is less than minLength, it is displayed as lengthErrorText.

Other error checking is performed by specifying validator. If a string other than Null is returned in the callback, the string is displayed as an error statement. If Null is returned, it is processed as no error.

The onSubmitted process is executed when the Enter key or other keys are pressed.

If suggestion is specified, suggestions will be displayed according to what you have entered.

If onDeleteSuggestion is specified, a delete button is displayed on the displayed suggestions, and if the button is pressed, the process is executed when the suggestion is deleted.

If enabled is false, the text is deactivated.

If readOnly is set to true, the activation is displayed, but the text cannot be changed.

If obscureText is set to true, the input string will be hidden. Please use this function for inputting passwords, etc.

If inputFormatters is specified, it is possible to restrict the characters to be entered.

フォーム用のテキストフィールド用のウィジェット。

FormController.keyを与えたForm配下に配置、もしくはformFormControllerを渡します。

formFormControllerを渡した場合、一緒にonSavedも渡してください。データの保存はonSavedの内容が実行されます。

initialValueFormController.valueから与えられた初期値を入力します。

内容が変更される度onChangedが実行されます。

FormController.validateが実行された場合、バリデーションとデータの保存を行ないます。

emptyErrorTextが指定されている時に限り、文字が入力されていない場合emptyErrorTextがエラーとして表示されます。 lengthErrorTextが指定されている時に限り、minLengthより入力された文字数が少ない場合lengthErrorTextとして表示されます。

それ以外のエラーチェックはvalidatorを指定することで行ないます。 コールバック内でNull以外を返すようにするとその文字列がエラー文として表示されます。Nullの場合はエラーなしとして処理されます。

Enterキーなどが押された場合の処理をonSubmittedが実行されます。

suggestionが指定されている場合、入力した内容に応じてサジェストが表示されます。

onDeleteSuggestionが指定されている場合、表示されたサジェストに削除ボタンが表示され、ボタンが押された場合、サジェスト削除時の処理が実行されます。

enabledfalseになるとテキストが非有効化されます。

readOnlytrueになっている場合は、有効化の表示になりますが、テキストが変更できなくなります。

obscureTexttrueになると入力された文字列が隠されます。パスワードの入力などにご利用ください。

inputFormattersが指定されると入力される文字を制限することが可能です。

Inheritance
Available Extensions

Constructors

FormTextField({FormController<TValue>? form, Key? key, TextEditingController? controller, FormAffixStyle? prefix, FormAffixStyle? suffix, FormStyle? style, TextInputType keyboardType = TextInputType.text, int? maxLength, VoidCallback? onTap, int? minLength, int maxLines = 1, int minLines = 1, bool expands = false, String? hintText, String? labelText, String? lengthErrorText, List<String> suggestion = const [], bool enabled = true, bool readOnly = false, bool obscureText = false, String? counterText = "", String? counterbuilder(String text)?, void onDeleteSuggestion(String value)?, String? validator(String? value)?, List<TextInputFormatter>? inputFormatters, TValue onSaved(String value)?, void onSubmitted(String? value)?, void onChanged(String? value)?, bool? showCursor, bool autofocus = false, bool autocorrect = false, bool selectOnFocus = false, FocusNode? focusNode, String? emptyErrorText, String? initialValue, VoidCallback? onTapSuggestion, SuggestionStyle? suggestionStyle, bool keepAlive = true, bool clearOnSubmitted = false})
Widgets for text fields for forms.
const

Properties

autocorrect bool
true to modify auto-entered text.
final
autofocus bool
If true, focus is automatically applied.
final
clearOnSubmitted bool
If Submitted, the contents will be erased.
final
controller TextEditingController?
Controller for text forms.
final
counterbuilder → (String? Function(String text)?)
Builder for building character count counters. It is used in preference to counterText.
final
counterText String?
Text of the character counter. Default is disabled.
final
emptyErrorText String?
Error text. Only displayed if no characters are entered.
final
enabled bool
If this is false, it is deactivated.
final
expands bool
If this is true, the text field will be stretched vertically. If there is no height limit, an error will result.
final
focusNode FocusNode?
Specifies the focus node.
final
form FormController<TValue>?
Context for forms.
final
hashCode int
The hash code for this object.
no setterinherited
hintText String?
Hint to be displayed on the form. Displayed when no text is entered.
final
initialValue String?
Initial value.
final
inputFormatters List<TextInputFormatter>?
List of TextInputFormatter.
final
keepAlive bool
If placed in a list, whether or not it should not be discarded on scrolling.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardType TextInputType
Mobile software keyboard type.
final
labelText String?
Label text for forms.
final
lengthErrorText String?
Text to be displayed if the number of characters is less than or equal to minLength. If this is not Null, an error is checked and displayed.
final
maxLength int?
Maximum number of strings. You will not be able to enter more than this.
final
maxLines int
Maximum number of lines. No more line breaks will be allowed.
final
minLength int?
Minimum number of strings. If lengthErrorText is specified, an error is displayed.
final
minLines int
Minimum number of lines; if a number greater than 1 is specified, the initial display of the form extends to the specified number of lines.
final
obscureText bool
If this is true, the input will be hidden. Use this to enter passwords, etc.
final
onChanged → (void Function(String? value)?)
Callback to be executed each time the value is changed.
final
onDeleteSuggestion → (void Function(String value)?)
If suggestions are displayed in suggestion, you can specify this to delete suggestions.
final
onSaved → (TValue Function(String value)?)
Callback executed when FormController.validate is executed.
final
onSubmitted → (void Function(String? value)?)
It is executed when the Enter button on the keyboard or the Submit button on the software keyboard is pressed.
final
onTap VoidCallback?
Executed when the form is tapped.
final
onTapSuggestion VoidCallback?
Callback executed when the window for suggestions is tapped.
final
prefix FormAffixStyle?
A widget that is placed in front of the form.
final
readOnly bool
If this is true, the form cannot be filled out and changed from its initial value.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectOnFocus bool
true to select all text when focused.
final
showCursor bool?
If this is true, the cursor is displayed.
final
style FormStyle?
Form Style.
final
suffix FormAffixStyle?
A widget that is placed after the form.
final
suggestion List<String>
If you want to display suggestions as you type, pass the suggestions here.
final
suggestionStyle SuggestionStyle?
Window style for suggestions.
final
validator → (String? Function(String? value)?)
Validator to be executed when FormController.validate is executed.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<StatefulWidget>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited