FTextField class final

A text field.

It lets the user enter text, either with hardware keyboard or with an onscreen keyboard. A FTextField is internally a FormField, therefore it can be used in a Form.

See:

Inheritance

Constructors

FTextField({FTextFieldStyle? style, Widget? label, String? hint, Widget? description, TextMagnifierConfiguration? magnifierConfiguration, TextEditingController? controller, FocusNode? focusNode, TextInputType? keyboardType, TextInputAction? textInputAction, TextCapitalization textCapitalization = TextCapitalization.none, TextAlign textAlign = TextAlign.start, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool autofocus = false, WidgetStatesController? statesController, bool obscureText = false, bool autocorrect = true, SmartDashesType? smartDashesType, SmartQuotesType? smartQuotesType, bool enableSuggestions = true, int? minLines, int? maxLines, bool expands = false, bool readOnly = false, bool? showCursor, int? maxLength, MaxLengthEnforcement? maxLengthEnforcement, ValueChanged<String>? onChange, VoidCallback? onEditingComplete, ValueChanged<String>? onSubmit, AppPrivateCommandCallback? onAppPrivateCommand, List<TextInputFormatter>? inputFormatters, bool enabled = true, bool? ignorePointers, bool enableInteractSelection = true, TextSelectionControls? selectionControls, DragStartBehavior dragStartBehavior = DragStartBehavior.start, MouseCursor? mouseCursor, ScrollPhysics? scrollPhysics, ScrollController? scrollController, Iterable<String>? autofillHints, String? restorationId, bool scribbleEnabled = true, bool enableIMEPersonalizedLearning = true, ContentInsertionConfiguration? contentInsertionConfiguration, EditableTextContextMenuBuilder? contextMenuBuilder = _contextMenuBuilder, bool canRequestFocus = true, UndoHistoryController? undoController, SpellCheckConfiguration? spellCheckConfiguration, Widget? suffix, FormFieldSetter<String>? onSaved, FormFieldValidator<String>? validator, String? initialValue, AutovalidateMode? autovalidateMode, String? forceErrorText, Widget errorBuilder(BuildContext, String) = _errorBuilder, Key? key})
Creates a FTextField.
const
FTextField.email({FTextFieldStyle? style, Widget? label = const Text('Email'), String? hint, Widget? description, TextMagnifierConfiguration? magnifierConfiguration, TextEditingController? controller, FocusNode? focusNode, TextInputType? keyboardType = TextInputType.emailAddress, TextInputAction? textInputAction = TextInputAction.next, TextCapitalization textCapitalization = TextCapitalization.none, TextAlign textAlign = TextAlign.start, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool autofocus = false, WidgetStatesController? statesController, bool obscureText = false, bool autocorrect = false, SmartDashesType? smartDashesType, SmartQuotesType? smartQuotesType, bool enableSuggestions = true, int? minLines, int? maxLines = 1, bool expands = false, bool readOnly = false, bool? showCursor, int? maxLength, MaxLengthEnforcement? maxLengthEnforcement, ValueChanged<String>? onChange, VoidCallback? onEditingComplete, ValueChanged<String>? onSubmit, AppPrivateCommandCallback? onAppPrivateCommand, List<TextInputFormatter>? inputFormatters, bool enabled = true, bool? ignorePointers, bool enableInteractSelection = true, TextSelectionControls? selectionControls, DragStartBehavior dragStartBehavior = DragStartBehavior.start, MouseCursor? mouseCursor, ScrollPhysics? scrollPhysics, ScrollController? scrollController, Iterable<String>? autofillHints = const [AutofillHints.email], String? restorationId, bool scribbleEnabled = true, bool enableIMEPersonalizedLearning = true, ContentInsertionConfiguration? contentInsertionConfiguration, EditableTextContextMenuBuilder? contextMenuBuilder = _contextMenuBuilder, bool canRequestFocus = true, UndoHistoryController? undoController, SpellCheckConfiguration? spellCheckConfiguration, Widget? suffix, FormFieldSetter<String>? onSaved, FormFieldValidator<String>? validator, String? initialValue, AutovalidateMode? autovalidateMode, String? forceErrorText, Widget errorBuilder(BuildContext, String) = _errorBuilder, Key? key})
Creates a FTextField configured for emails.
const
FTextField.multiline({FTextFieldStyle? style, Widget? label, String? hint, Widget? description, TextMagnifierConfiguration? magnifierConfiguration, TextEditingController? controller, FocusNode? focusNode, TextInputType? keyboardType, TextInputAction? textInputAction, TextCapitalization textCapitalization = TextCapitalization.sentences, TextAlign textAlign = TextAlign.start, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool autofocus = false, WidgetStatesController? statesController, bool obscureText = false, bool autocorrect = true, SmartDashesType? smartDashesType, SmartQuotesType? smartQuotesType, bool enableSuggestions = true, int? minLines = 4, int? maxLines, bool expands = false, bool readOnly = false, bool? showCursor, int? maxLength, MaxLengthEnforcement? maxLengthEnforcement, ValueChanged<String>? onChange, VoidCallback? onEditingComplete, ValueChanged<String>? onSubmit, AppPrivateCommandCallback? onAppPrivateCommand, List<TextInputFormatter>? inputFormatters, bool enabled = true, bool? ignorePointers, bool enableInteractSelection = true, TextSelectionControls? selectionControls, DragStartBehavior dragStartBehavior = DragStartBehavior.start, MouseCursor? mouseCursor, ScrollPhysics? scrollPhysics, ScrollController? scrollController, Iterable<String>? autofillHints, String? restorationId, bool scribbleEnabled = true, bool enableIMEPersonalizedLearning = true, ContentInsertionConfiguration? contentInsertionConfiguration, EditableTextContextMenuBuilder? contextMenuBuilder = _contextMenuBuilder, bool canRequestFocus = true, UndoHistoryController? undoController, SpellCheckConfiguration? spellCheckConfiguration, Widget? suffix, FormFieldSetter<String>? onSaved, FormFieldValidator<String>? validator, String? initialValue, AutovalidateMode? autovalidateMode, String? forceErrorText, Widget errorBuilder(BuildContext, String) = _errorBuilder, Key? key})
Creates a FTextField configured for multiline inputs.
const
FTextField.password({FTextFieldStyle? style, Widget? label = const Text('Password'), String? hint, Widget? description, TextMagnifierConfiguration? magnifierConfiguration, TextEditingController? controller, FocusNode? focusNode, TextInputType? keyboardType, TextInputAction? textInputAction = TextInputAction.next, TextCapitalization textCapitalization = TextCapitalization.none, TextAlign textAlign = TextAlign.start, TextAlignVertical? textAlignVertical, TextDirection? textDirection, bool autofocus = false, WidgetStatesController? statesController, bool obscureText = true, bool autocorrect = false, SmartDashesType? smartDashesType, SmartQuotesType? smartQuotesType, bool enableSuggestions = true, int? minLines, int? maxLines = 1, bool expands = false, bool readOnly = false, bool? showCursor, int? maxLength, MaxLengthEnforcement? maxLengthEnforcement, ValueChanged<String>? onChange, VoidCallback? onEditingComplete, ValueChanged<String>? onSubmit, AppPrivateCommandCallback? onAppPrivateCommand, List<TextInputFormatter>? inputFormatters, bool enabled = true, bool? ignorePointers, bool enableInteractSelection = true, TextSelectionControls? selectionControls, DragStartBehavior dragStartBehavior = DragStartBehavior.start, MouseCursor? mouseCursor, ScrollPhysics? scrollPhysics, ScrollController? scrollController, Iterable<String>? autofillHints = const [AutofillHints.password], String? restorationId, bool scribbleEnabled = true, bool enableIMEPersonalizedLearning = true, ContentInsertionConfiguration? contentInsertionConfiguration, EditableTextContextMenuBuilder? contextMenuBuilder = _contextMenuBuilder, bool canRequestFocus = true, UndoHistoryController? undoController, SpellCheckConfiguration? spellCheckConfiguration, Widget? suffix, FormFieldSetter<String>? onSaved, FormFieldValidator<String>? validator, String? initialValue, AutovalidateMode? autovalidateMode, String? forceErrorText, Widget errorBuilder(BuildContext, String) = _errorBuilder, Key? key})
Creates a FTextField configured for passwords.
const

Properties

autocorrect bool
Whether to enable autocorrection. Defaults to true.
final
autofillHints Iterable<String>?
A list of strings that helps the autofill service identify the type of this text input.
final
autofocus bool
Whether this text field should focus itself if nothing else is already focused. Defaults to false.
final
autovalidateMode AutovalidateMode?
Used to enable/disable this form field auto validation and update its error text.
final
canRequestFocus bool
Determine whether this text field can request the primary focus.
final
contentInsertionConfiguration ContentInsertionConfiguration?
Configuration of handler for media content inserted via the system input method.
final
contextMenuBuilder EditableTextContextMenuBuilder?
Builds the text selection toolbar when requested by the user.
final
controller TextEditingController?
Controls the text being edited. If null, this widget will create its own TextEditingController.
final
description Widget?
The description text.
final
dragStartBehavior DragStartBehavior
Determines the way that drag start behavior is handled. By default, the drag start behavior is DragStartBehavior.start.
final
enabled bool
If false the text field is "disabled": it ignores taps. Defaults to true.
final
enableIMEPersonalizedLearning bool
Whether to enable that the IME update personalized data such as typing history and user dictionary data.
final
enableInteractSelection bool
Whether to enable user interface affordances for changing the text selection. Defaults to true.
final
enableSuggestions bool
Whether to show input suggestions as the user types. Defaults to true.
final
errorBuilder Widget Function(BuildContext, String)
A builder that transforms a FormFieldState.errorText into a widget. Defaults to a Text widget.
final
expands bool
Whether this widget's height will be sized to fill its parent. Defaults to false.
final
focusNode FocusNode?
Defines the keyboard focus for this FTextField.
final
forceErrorText String?
An optional property that forces the FormFieldState into an error state by directly setting the FormFieldState.errorText property without running the validator function.
final
hashCode int
The hash code for this object.
no setterinherited
hint String?
The text to display when the text field is empty.
final
ignorePointers bool?
Determines whether this widget ignores pointer events. Defaults to null, and when null, does nothing.
final
initialValue String?
An optional value to initialize the form field to, or null otherwise.
final
inputFormatters List<TextInputFormatter>?
Optional input validation and formatting overrides.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardType TextInputType?
The type of keyboard to use for editing the text. Defaults to TextInputType.text if maxLines is one and TextInputType.multiline otherwise.
final
label Widget?
The label above a text field.
final
magnifierConfiguration TextMagnifierConfiguration?
The configuration for the magnifier of this text field.
final
maxLength int?
The maximum number of characters (Unicode grapheme clusters) to allow in the text field.
final
maxLengthEnforcement MaxLengthEnforcement?
Determines how the maxLength limit should be enforced.
final
maxLines int?
The maximum number of lines to show at one time, wrapping if necessary.
final
minLines int?
The minimum number of lines to occupy when the content spans fewer lines.
final
mouseCursor MouseCursor?
The cursor for a mouse pointer when it enters or is hovering over the widget.
final
obscureText bool
Whether to hide the text being edited (e.g., for passwords). Defaults to false.
final
onAppPrivateCommand AppPrivateCommandCallback?
This is used to receive a private command from the input method.
final
onChange ValueChanged<String>?
Called when the user initiates a change to the TextField's value: when they have inserted or deleted text.
final
onEditingComplete VoidCallback?
Called when the user submits editable content (e.g., user presses the "done" button on the keyboard).
final
onSaved FormFieldSetter<String>?
An optional method to call with the final value when the form is saved via FormState.save.
final
onSubmit ValueChanged<String>?
Called when the user indicates that they are done editing the text in the field.
final
readOnly bool
Whether the text can be changed. Defaults to false.
final
restorationId String?
Restoration ID to save and restore the state of the text field.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scribbleEnabled bool
Whether iOS 14 Scribble features are enabled for this Defaults to true.
final
scrollController ScrollController?
The ScrollController to use when vertically scrolling the input. If null, it will instantiate a new ScrollController.
final
scrollPhysics ScrollPhysics?
The ScrollPhysics to use when vertically scrolling the input. If not specified, it will behave according to the current platform.
final
selectionControls TextSelectionControls?
Optional delegate for building the text selection handles.
final
showCursor bool?
Whether to show cursor.
final
smartDashesType SmartDashesType?
Whether to allow the platform to automatically format dashes.
final
smartQuotesType SmartQuotesType?
Whether to allow the platform to automatically format quotes.
final
spellCheckConfiguration SpellCheckConfiguration?
Configuration that details how spell check should be performed.
final
statesController WidgetStatesController?
Represents the interactive "state" of this widget in terms of a set of WidgetStates, including WidgetState.disabled, WidgetState.hovered, WidgetState.error, and WidgetState.focused.
final
style FTextFieldStyle?
The text field's style. Defaults to FThemeData.textFieldStyle.
final
suffix Widget?
The suffix icon.
final
textAlign TextAlign
How the text should be aligned horizontally.
final
textAlignVertical TextAlignVertical?
How the text should be aligned vertically.
final
textCapitalization TextCapitalization
Configures how the platform keyboard will select an uppercase or lowercase keyboard. Defaults to TextCapitalization.none.
final
textDirection TextDirection?
The directionality of the text. Defaults to the ambient Directionality, if any.
final
textInputAction TextInputAction?
The type of action button to use for the keyboard.
final
undoController UndoHistoryController?
Controls the undo state.
final
validator FormFieldValidator<String>?
An optional method that validates an input. Returns an error string to display if the input is invalid, or null otherwise.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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.
override
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