TextField class

Desktop text field.

See also:

Inheritance

Constructors

TextField({Key? key, bool autocorrect = true, bool autofocus = false, Clip clipBehavior = Clip.hardEdge, TextEditingController? controller, double cursorWidth = _kCursorWidth, BoxDecoration? decoration, bool enabled = true, bool expands = false, FocusNode? focusNode, List<TextInputFormatter>? inputFormatters, ScrollController? scrollController, int? maxLength, int? maxLines = 1, int? minLines, ValueChanged<String>? onChanged, VoidCallback? onEditingComplete, ValueChanged<String>? onSubmitted, TextDirection? textDirection, GestureTapCallback? onTap, String? placeholder, TextStyle? placeholderStyle, bool readOnly = false, String? restorationId, bool? showCursor, StrutStyle? strutStyle, TextStyle? style, String obscuringCharacter = '•', bool obscureText = false, TextAlign textAlign = TextAlign.start, bool enableSuggestions = false, DragStartBehavior dragStartBehavior = DragStartBehavior.down, double? cursorHeight, Iterable<String>? autofillHints = const <String>[], bool enableIMEPersonalizedLearning = true, bool enableInteractiveSelection = true, AppPrivateCommandCallback? onAppPrivateCommand, TextSelectionControls? selectionControls, TextInputAction? textInputAction, ScrollBehavior? scrollBehavior, Widget? prefix, Widget? suffix, OverlayVisibilityMode prefixMode = OverlayVisibilityMode.always, OverlayVisibilityMode suffixMode = OverlayVisibilityMode.always, SmartDashesType? smartDashesType, SmartQuotesType? smartQuotesType, TextInputType? keyboardType, EdgeInsets scrollPadding = const EdgeInsets.all(0), TextCapitalization textCapitalization = TextCapitalization.none, MaxLengthEnforcement? maxLengthEnforcement, EdgeInsets? padding})
Creates a desktop text field.
const

Properties

autocorrect bool
Whether to enable autocorrection.
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.
final
clipBehavior Clip
final
controller TextEditingController?
final
cursorHeight double?
How tall the cursor will be.
final
cursorWidth double
How thick the cursor will be.
final
decoration BoxDecoration?
Controls the BoxDecoration of the box behind the text input.
final
dragStartBehavior DragStartBehavior
Determines the way that drag start behavior is handled.
final
enabled bool
final
enableIMEPersonalizedLearning bool
Whether to enable that the IME update personalized data such as typing history and user dictionary data.
final
enableInteractiveSelection bool
Whether to enable user interface affordances for changing the text selection.
final
enableSuggestions bool
Whether to show input suggestions as the user types.
final
expands bool
Whether this widget's height will be sized to fill its parent.
final
focusNode FocusNode?
An optional focus node to use as the focus node for this widget.
final
hashCode int
The hash code for this object.
no setterinherited
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.
final
maxLength int?
Characters
final
maxLengthEnforcement MaxLengthEnforcement?
Platform specific behaviors
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
obscureText bool
Whether to hide the text being edited (e.g., for passwords).
final
obscuringCharacter String
Character used for obscuring text if obscureText is true.
final
onAppPrivateCommand AppPrivateCommandCallback?
This is used to receive a private command from the input method.
final
onChanged 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
onSubmitted ValueChanged<String>?
Called when the user indicates that they are done editing the text in the field.
final
onTap GestureTapCallback?
Called for the first tap in a series of taps.
final
padding EdgeInsets?
final
placeholder String?
final
placeholderStyle TextStyle?
final
prefix Widget?
An optional Widget to display before the text.
final
prefixMode OverlayVisibilityMode
Controls the visibility of the prefix widget based on the state of text entry when the prefix argument is not null.
final
readOnly bool
Whether the text can be changed.
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
scrollBehavior ScrollBehavior?
final
scrollController ScrollController?
The ScrollController to use when vertically scrolling the input.
final
scrollPadding EdgeInsets
Configures padding to edges surrounding a Scrollable when the Textfield scrolls into view.
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
strutStyle StrutStyle?
The strut style used for the vertical layout.
final
style TextStyle?
final
suffix Widget?
An optional Widget to display after the text.
final
suffixMode OverlayVisibilityMode
Controls the visibility of the suffix widget based on the state of text entry when the suffix argument is not null.
final
textAlign TextAlign
How the text should be aligned horizontally.
final
textCapitalization TextCapitalization
Configures how the platform keyboard will select an uppercase or lowercase keyboard.
final
textDirection TextDirection?
The directionality of the text.
final
textInputAction TextInputAction?
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<TextField>
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