Text Form Field

The Text Form Field widget is a versatile input field that allows users to enter and edit text. It offers a wide range of customization options for appearance, validation, and behavior.

General Properties

Property
Description

initialValue

The initial text to display in the field.

controller

An expression to control the text field's value programmatically.

enabled

If false, the text field is disabled.

readOnly

If true, the text in the field cannot be modified by the user.

autoFocus

If true, the text field will automatically be focused when the screen loads.

obscureText

If true, the entered text will be obscured (e.g., for passwords).

keyboardType

The type of keyboard to display (e.g., text, number, emailAddress).

textInputAction

The action to be performed when the user presses the "enter" or "done" key on the keyboard.

textAlign

The horizontal alignment of the text within the field.

maxLength

The maximum number of characters allowed in the field.

minLines

The minimum number of lines the field will occupy.

maxLines

The maximum number of lines the field can expand to.

Styling Properties

Property
Description

textStyle

The TextStyle for the text entered by the user.

hintText

Placeholder text to display when the field is empty.

hintStyle

The TextStyle for the hint text.

labelText

Text that "floats" above the field when it is focused.

labelStyle

The TextStyle for the label text.

fillColor

The background color of the text field.

cursorColor

The color of the blinking cursor.

contentPadding

The padding around the text within the field.

Border Properties

The text field has different border styles for various states (enabled, disabled, focused, error). Each border has the following properties:

Property
Description

borderType

The type of border (e.g., underline, outline).

borderStyle

The style of the border (solid, dashed).

borderWidth

The thickness of the border.

borderColor

The color of the border.

borderRadius

The corner radius for outline-style borders.

Validation and Error Properties

Property
Description

validationRules

A list of rules to validate the input.

regex

A regular expression pattern for validation.

errorText

The text to display when a validation error occurs.

errorStyle

The TextStyle for the error text.

Events

Property
Description

onChanged

An action to trigger whenever the text in the field changes.

onSubmit

An action to trigger when the user submits the field (e.g., by pressing "done" on the keyboard).

debounceValue

The delay in milliseconds before the onChanged action is triggered.


Default Properties

The Text Form Field widget supports the following section of Default Properties

Layout

  • width

  • height

  • padding

  • margin

  • align

Last updated