XTextField class

A flexible text field widget supporting:

  • Standard text input
  • File picker
  • Dropdown list
  • Date picker
  • Time picker

Includes:

  • Customizable style
  • Validation
  • Character counter
  • Common callbacks
Inheritance

Constructors

XTextField({Key? key, Object groupId = EditableText, String? restorationId, TextEditingController? controller, FocusNode? focusNode, InputDecoration? decoration, TextStyle? textStyle, StrutStyle? strutStyle, TextDirection? textDirection, TextAlignVertical? textAlignVertical, TextStyle? labelStyle, TextStyle? hintStyle, String? label, String? labelOnLine, String? hintText, bool isRequired = false, bool isEnable = true, Widget? prefixIcon, Widget? suffixIcon, TextInputType inputType = TextInputType.text, XTextFieldType fieldType = XTextFieldType.normal, TextCapitalization textCapitalization = TextCapitalization.sentences, int minLines = 1, int maxLines = 1, int maxLength = 500, bool isShowCounter = false, void onChanged(String)?, VoidCallback? onTap, bool onTapAlwaysCalled = false, TapRegionCallback? onTapOutside, TapRegionUpCallback? onTapUpOutside, VoidCallback? onEditingComplete, ValueChanged<String>? onFieldSubmitted, TextInputAction textInputAction = TextInputAction.next, XTextFieldStyle? style, XTextFieldFileOptions? fileOptions, XTextFieldDropdownOptions? dropdownOptions, XTextFieldDatePickerOptions? datePickerOptions, XTextFieldTimePickerOptions? timePickerOptions, String? validator(String?)?, void onFileSelected(XFile?)?, void onDropdownChanged(dynamic)?, void onDateSelected(DateTime?)?, void onTimeSelected(TimeOfDay?)?, bool isReadOnly = false, bool isObscureText = false, TextAlign textAlign = TextAlign.start, EdgeInsets? contentPadding, AutovalidateMode? autovalidateMode, String? asyncErrorText, void onSaved(String?)?, FloatingLabelBehavior floatingLabelBehavior = .auto, bool autofocus = false, bool? showCursor, String obscuringCharacter = '•', bool autocorrect = true, SmartDashesType? smartDashesType, SmartQuotesType? smartQuotesType, bool enableSuggestions = true, MaxLengthEnforcement? maxLengthEnforcement, bool expands = false, List<TextInputFormatter>? inputFormatters, bool? enabled, bool? ignorePointers, double cursorWidth = 2.0, double? cursorHeight, Radius? cursorRadius, Color? cursorColor = Colors.black87, Color? cursorErrorColor, Brightness? keyboardAppearance, EdgeInsets scrollPadding = const EdgeInsets.all(20.0), bool? enableInteractiveSelection, bool? selectAllOnFocus, TextSelectionControls? selectionControls, InputCounterWidgetBuilder? buildCounter, ScrollPhysics? scrollPhysics, Iterable<String>? autofillHints, ScrollController? scrollController, bool enableIMEPersonalizedLearning = true, MouseCursor? mouseCursor, EditableTextContextMenuBuilder? contextMenuBuilder, SpellCheckConfiguration? spellCheckConfiguration, TextMagnifierConfiguration? magnifierConfiguration, UndoHistoryController? undoController, AppPrivateCommandCallback? onAppPrivateCommand, bool? cursorOpacityAnimates, BoxHeightStyle? selectionHeightStyle, BoxWidthStyle? selectionWidthStyle, DragStartBehavior dragStartBehavior = DragStartBehavior.start, ContentInsertionConfiguration? contentInsertionConfiguration, MaterialStatesController? statesController, Clip clipBehavior = Clip.hardEdge, bool stylusHandwritingEnabled = EditableText.defaultStylusHandwritingEnabled, bool canRequestFocus = true, List<Locale>? hintLocales, XLook look = XLook.standard})
Creates a new customizable XTextField.
const

Properties

asyncErrorText → String?
For async/server-side validation errors (e.g., "email already exists") This is separate from the synchronous validator and will be displayed alongside validator errors. Clear this when user changes the field.
final
autocorrect → bool
Whether to enable autocorrect.
final
autofillHints → Iterable<String>?
Autofill hints.
final
autofocus → bool
Whether this field should be focused initially.
final
autovalidateMode → AutovalidateMode?
Controls when validation occurs. See AutovalidateMode for details.
final
buildCounter → InputCounterWidgetBuilder?
Custom max length counter builder.
final
canRequestFocus → bool
Whether this field can request focus.
final
clipBehavior → Clip
Clip behavior of text field.
final
contentInsertionConfiguration → ContentInsertionConfiguration?
Content insertion configuration.
final
contentPadding → EdgeInsets?
Padding inside the text field. If null, default padding is applied.
final
contextMenuBuilder → EditableTextContextMenuBuilder?
Context menu builder.
final
controller → TextEditingController?
Controller for managing the text field's value. If not provided, an internal controller is created.
final
cursorColor → Color?
Color of the text cursor. Defaults to Colors.black87.
final
cursorErrorColor → Color?
Cursor error color.
final
cursorHeight → double?
Height of cursor.
final
cursorOpacityAnimates → bool?
Whether cursor opacity animates.
final
cursorRadius → Radius?
Radius for cursor corners.
final
cursorWidth → double
Width of cursor.
final
datePickerOptions → XTextFieldDatePickerOptions?
Options for date picker field.
final
decoration → InputDecoration?
Full InputDecoration override for TextFormField.
final
dragStartBehavior → DragStartBehavior
Drag start behavior.
final
Options for dropdown field.
final
enabled → bool?
Optional direct enabled override.
final
enableIMEPersonalizedLearning → bool
Whether IME personalized learning is enabled.
final
enableInteractiveSelection → bool?
Whether interactive selection is enabled.
final
enableSuggestions → bool
Whether to enable suggestions.
final
expands → bool
Whether this field expands to fill available space.
final
fieldType → XTextFieldType
Type of field to display. Defaults to XTextFieldType.normal.
final
fileOptions → XTextFieldFileOptions?
Options for file picker field.
final
floatingLabelBehavior → FloatingLabelBehavior
Behavior of the floating label. Defaults to FloatingLabelBehavior.auto.
final
focusNode → FocusNode?
Focus node for controlling focus state.
final
groupId → Object
Identifier used by EditableText to group text fields for shared behavior.
final
hashCode → int
The hash code for this object.
no setterinherited
hintLocales → List<Locale>?
Hint locales used by input method.
final
hintStyle → TextStyle?
Hint text style displayed when the field is empty.
final
hintText → String?
Hint text displayed when the field is empty.
final
ignorePointers → bool?
Whether to ignore pointers.
final
inputFormatters → List<TextInputFormatter>?
Text input formatters.
final
inputType → TextInputType
Type of keyboard to use for text input. Defaults to TextInputType.text.
final
isEnable → bool
Whether the field is enabled. Defaults to true.
final
isObscureText → bool
Whether to obscure the text (for password fields).
final
isReadOnly → bool
Whether the field is read-only. Defaults to false.
final
isRequired → bool
Whether the field is required. Defaults to false.
final
isShowCounter → bool
Whether to show character counter below the field. Defaults to false.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardAppearance → Brightness?
Keyboard appearance brightness.
final
label → String?
Label text style displayed above the field.
final
labelOnLine → String?
Label text displayed on the same line as the field.
final
labelStyle → TextStyle?
Label text style displayed above the field.
final
look → XLook
Visual look preset. Defaults to XLook.standard (existing package look).
final
magnifierConfiguration → TextMagnifierConfiguration?
Magnifier configuration.
final
maxLength → int
Maximum length of input text.
final
maxLengthEnforcement → MaxLengthEnforcement?
Max length enforcement behavior.
final
maxLines → int
Minimum lines of input.
final
minLines → int
Minimum lines of input.
final
mouseCursor → MouseCursor?
Mouse cursor when hovering this field.
final
obscuringCharacter → String
Character used for obscured text.
final
onAppPrivateCommand → AppPrivateCommandCallback?
Callback for app private command.
final
onChanged → void Function(String)?
Callback when the field value changes.
final
onDateSelected → void Function(DateTime?)?
final
onDropdownChanged → void Function(dynamic)?
final
onEditingComplete → VoidCallback?
Callback for editing completion.
final
onFieldSubmitted → void Function(String)?
Callback when user submits text from keyboard action.
final
onFileSelected → void Function(XFile?)?
final
onSaved → void Function(String?)?
Optional callback that's called when formKey.currentState!.save() is invoked. This is a standard Flutter Form API feature for collecting form data. If you prefer using controllers, you can ignore this.
final
onTap → VoidCallback?
Callback when the field is tapped.
final
onTapAlwaysCalled → bool
Whether to call onTap for each tap even when focused.
final
onTapOutside → TapRegionCallback?
Callback when tapped outside of this text field.
final
onTapUpOutside → TapRegionUpCallback?
Callback when tap-up happens outside of this text field.
final
onTimeSelected → void Function(TimeOfDay?)?
final
prefixIcon → Widget?
Prefix icon widget. For file picker, dropdown, date picker, and time picker types, it's recommended to use an IconButton to trigger the respective action.
final
restorationId → String?
Restoration ID for state restoration.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scrollController → ScrollController?
Scroll controller for editable text.
final
scrollPadding → EdgeInsets
Scroll padding around editable region.
final
scrollPhysics → ScrollPhysics?
Scroll physics for editable text.
final
selectAllOnFocus → bool?
Whether to select all text on focus.
final
selectionControls → TextSelectionControls?
Text selection controls.
final
selectionHeightStyle → BoxHeightStyle?
Selection height style.
final
selectionWidthStyle → BoxWidthStyle?
Selection width style.
final
showCursor → bool?
Whether to show cursor.
final
smartDashesType → SmartDashesType?
Smart dashes behavior.
final
smartQuotesType → SmartQuotesType?
Smart quotes behavior.
final
spellCheckConfiguration → SpellCheckConfiguration?
Spell check configuration.
final
statesController → MaterialStatesController?
State controller for text field material states.
final
strutStyle → StrutStyle?
Strut style for vertical text metrics.
final
style → XTextFieldStyle?
Style customization for the text field. If null, default styles are applied.
final
stylusHandwritingEnabled → bool
Whether stylus handwriting is enabled.
final
suffixIcon → Widget?
Suffix icon widget. For file picker, dropdown, date picker, and time picker types, it's recommended to use an IconButton to trigger the respective action.
final
textAlign → TextAlign
Text alignment within the field. Defaults to TextAlign.start.
final
textAlignVertical → TextAlignVertical?
Vertical alignment for text.
final
textCapitalization → TextCapitalization
Text capitalization behavior. Defaults to TextCapitalization.sentences.
final
textDirection → TextDirection?
Text direction.
final
textInputAction → TextInputAction
Action button on the keyboard. Defaults to TextInputAction.next.
final
textStyle → TextStyle?
Text style within the field.
final
timePickerOptions → XTextFieldTimePickerOptions?
Options for time picker field.
final
undoController → UndoHistoryController?
Undo history controller.
final
validator → String? Function(String?)?
Field validator - accepts standard Flutter validator function Use XFormValidator for common validations:
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<XTextField>
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, int wrapWidth = 65}) → 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