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, TextEditingController? controller, TextStyle? textStyle, 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, TextInputAction textInputAction = TextInputAction.next, XTextFieldStyle? style, XTextFieldFileOptions? fileOptions, XTextFieldDropdownOptions? dropdownOptions, XTextFieldDatePickerOptions? datePickerOptions, XTextFieldTimePickerOptions? timePickerOptions, String? validator(String?)?, void onFileSelected(File?)?, 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, Color? cursorColor = Colors.black87})
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
autovalidateMode AutovalidateMode?
Controls when validation occurs. See AutovalidateMode for details.
final
contentPadding EdgeInsets?
Padding inside the text field. If null, default padding is applied.
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
datePickerOptions XTextFieldDatePickerOptions?
Options for date picker field.
final
Options for dropdown field.
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
hashCode int
The hash code for this object.
no setterinherited
hintStyle TextStyle?
Hint text style displayed when the field is empty.
final
hintText String?
Hint text displayed when the field is empty.
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
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
maxLength int
Maximum length of input text.
final
maxLines int
Minimum lines of input.
final
minLines int
Minimum lines of input.
final
onChanged → void Function(String)?
Callback when the field value changes.
final
onDateSelected → void Function(DateTime?)?
final
onDropdownChanged → void Function(dynamic)?
final
onFileSelected → void Function(File?)?
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
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
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
style XTextFieldStyle?
Style customization for the text field. If null, default styles are applied.
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
textCapitalization TextCapitalization
Text capitalization behavior. Defaults to TextCapitalization.sentences.
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
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