UIProTextField class

A customizable text field with built-in validation, focus animations, and password visibility toggle.

UIProTextField provides a consistent input experience across your app.

Example:

UIProTextField(
  hint: "Email",
  controller: emailController,
  keyboardType: TextInputType.emailAddress,
  errorText: emailError,
)

Email field with built-in validation:

UIProTextField.email(
  controller: emailController,
  validateNotEmpty: true, // Shows error if empty
)

Password field with visibility toggle:

UIProTextField.password(
  hint: "Password",
  controller: passwordController,
  validateNotEmpty: true,
)
Inheritance

Constructors

UIProTextField({Key? key, TextEditingController? controller, String? hint, String? label, String? errorText, String? helperText, IconData? prefixIcon, Widget? prefix, IconData? suffixIcon, Widget? suffix, TextInputType? keyboardType, TextInputAction? textInputAction, bool isPassword = false, bool enabled = true, bool readOnly = false, bool autofocus = false, int? maxLines = 1, int? minLines, int? maxLength, List<TextInputFormatter>? inputFormatters, ValueChanged<String>? onChanged, VoidCallback? onEditingComplete, ValueChanged<String>? onSubmitted, VoidCallback? onTap, FocusNode? focusNode, TextCapitalization textCapitalization = TextCapitalization.none, String obscuringCharacter = '•', double? borderRadius, Color? backgroundColor, Color? borderColor, Color? focusedBorderColor, Color? errorBorderColor, EdgeInsets? contentPadding, TextStyle? textStyle, TextStyle? hintStyle, TextStyle? labelStyle, TextStyle? errorStyle, bool showCounter = false, double? borderWidth, bool animateFocus = true, UIProTextFieldVariant variant = UIProTextFieldVariant.outlined, UIProTextFieldType fieldType = UIProTextFieldType.text, bool validateNotEmpty = false, String emptyErrorMessage = "This field is required", String invalidEmailMessage = "Please enter a valid email", int minPasswordLength = 6, String shortPasswordMessage = "Password must be at least 6 characters"})
Creates a customizable text field.
const
UIProTextField.email({Key? key, TextEditingController? controller, String? hint = "Email", String? label, String? errorText, String? helperText, IconData? prefixIcon = Icons.email_outlined, Widget? prefix, IconData? suffixIcon, Widget? suffix, TextInputAction? textInputAction, bool enabled = true, bool readOnly = false, bool autofocus = false, int? maxLength, List<TextInputFormatter>? inputFormatters, ValueChanged<String>? onChanged, VoidCallback? onEditingComplete, ValueChanged<String>? onSubmitted, VoidCallback? onTap, FocusNode? focusNode, double? borderRadius, Color? backgroundColor, Color? borderColor, Color? focusedBorderColor, Color? errorBorderColor, EdgeInsets? contentPadding, TextStyle? textStyle, TextStyle? hintStyle, TextStyle? labelStyle, TextStyle? errorStyle, bool showCounter = false, double? borderWidth, bool animateFocus = true, UIProTextFieldVariant variant = UIProTextFieldVariant.outlined, bool validateNotEmpty = false, String emptyErrorMessage = "Email is required", String invalidEmailMessage = "Please enter a valid email"})
Creates an email text field with built-in email validation.
const
UIProTextField.multiline({Key? key, TextEditingController? controller, String? hint, String? label, String? errorText, String? helperText, IconData? prefixIcon, Widget? prefix, IconData? suffixIcon, Widget? suffix, bool enabled = true, bool readOnly = false, bool autofocus = false, int? maxLines = 5, int? minLines = 3, int? maxLength, List<TextInputFormatter>? inputFormatters, ValueChanged<String>? onChanged, VoidCallback? onEditingComplete, VoidCallback? onTap, FocusNode? focusNode, TextCapitalization textCapitalization = TextCapitalization.sentences, double? borderRadius, Color? backgroundColor, Color? borderColor, Color? focusedBorderColor, Color? errorBorderColor, EdgeInsets? contentPadding, TextStyle? textStyle, TextStyle? hintStyle, TextStyle? labelStyle, TextStyle? errorStyle, bool showCounter = true, double? borderWidth, bool animateFocus = true, UIProTextFieldVariant variant = UIProTextFieldVariant.outlined, bool validateNotEmpty = false, String emptyErrorMessage = "This field is required"})
Creates a multiline text area.
const
UIProTextField.password({Key? key, TextEditingController? controller, String? hint = "Password", String? label, String? errorText, String? helperText, IconData? prefixIcon = Icons.lock_outline, Widget? prefix, TextInputAction? textInputAction, bool enabled = true, bool readOnly = false, bool autofocus = false, int? maxLength, List<TextInputFormatter>? inputFormatters, ValueChanged<String>? onChanged, VoidCallback? onEditingComplete, ValueChanged<String>? onSubmitted, VoidCallback? onTap, FocusNode? focusNode, String obscuringCharacter = '•', double? borderRadius, Color? backgroundColor, Color? borderColor, Color? focusedBorderColor, Color? errorBorderColor, EdgeInsets? contentPadding, TextStyle? textStyle, TextStyle? hintStyle, TextStyle? labelStyle, TextStyle? errorStyle, bool showCounter = false, double? borderWidth, bool animateFocus = true, UIProTextFieldVariant variant = UIProTextFieldVariant.outlined, bool validateNotEmpty = false, String emptyErrorMessage = "Password is required", int minPasswordLength = 6, String shortPasswordMessage = "Password must be at least 6 characters"})
Creates a password text field with visibility toggle.
const

Properties

animateFocus bool
Whether to animate focus changes.
final
autofocus bool
Whether to autofocus this field.
final
backgroundColor Color?
Custom background color (overrides theme).
final
borderColor Color?
Custom border color (overrides theme).
final
borderRadius double?
Custom border radius (overrides theme).
final
borderWidth double?
Border width.
final
contentPadding EdgeInsets?
Custom content padding (overrides theme).
final
controller TextEditingController?
Text editing controller.
final
emptyErrorMessage String
Custom error message for empty field.
final
enabled bool
Whether the field is enabled.
final
errorBorderColor Color?
Custom error border color.
final
errorStyle TextStyle?
Custom error style.
final
errorText String?
Error text to display below the field. If null and validation fails, shows auto-generated error.
final
fieldType UIProTextFieldType
Text field type for validation.
final
focusedBorderColor Color?
Custom focused border color (overrides theme).
final
focusNode FocusNode?
Focus node.
final
hashCode int
The hash code for this object.
no setterinherited
helperText String?
Helper text to display below the field.
final
hint String?
Hint text shown when field is empty.
final
hintStyle TextStyle?
Custom hint style.
final
inputFormatters List<TextInputFormatter>?
Input formatters.
final
invalidEmailMessage String
Custom error message for invalid email.
final
isPassword bool
Whether this is a password field with visibility toggle.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardType TextInputType?
Keyboard type.
final
label String?
Label text shown above the field.
final
labelStyle TextStyle?
Custom label style.
final
maxLength int?
Maximum length of input.
final
maxLines int?
Maximum number of lines.
final
minLines int?
Minimum number of lines.
final
minPasswordLength int
Minimum password length for validation.
final
obscuringCharacter String
Obscuring character for password fields.
final
onChanged ValueChanged<String>?
Called when text changes.
final
onEditingComplete VoidCallback?
Called when editing is complete.
final
onSubmitted ValueChanged<String>?
Called when user submits.
final
onTap VoidCallback?
Called when field is tapped.
final
prefix Widget?
Custom prefix widget (overrides prefixIcon).
final
prefixIcon IconData?
Prefix icon.
final
readOnly bool
Whether the field is read-only.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shortPasswordMessage String
Custom error message for short password.
final
showCounter bool
Whether to show character counter.
final
suffix Widget?
Custom suffix widget (overrides suffixIcon).
final
suffixIcon IconData?
Suffix icon.
final
textCapitalization TextCapitalization
Text capitalization.
final
textInputAction TextInputAction?
Text input action.
final
textStyle TextStyle?
Custom text style.
final
validateNotEmpty bool
Whether to validate that field is not empty.
final
variant UIProTextFieldVariant
Text field variant.
final

Methods

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