Skip to main content

TextFormField

The Stac TextFormField allows you to build a Flutter TextFormField widget using JSON. To know more about the TextFormField widget in Flutter, refer to the official documentation.

Properties​

PropertyTypeDescription
idString?The identifier for the text form field.
compareIdString?The identifier to compare with another text form field.
decorationStacInputDecoration?The decoration to show around the text form field.
initialValueString?The initial value of the text form field.
keyboardTypeStacTextInputType?The type of keyboard to use for editing the text.
textInputActionTextInputAction?The action button to use for the keyboard.
textCapitalizationTextCapitalizationHow the text should be capitalized. Defaults to TextCapitalization.none.
styleStacTextStyle?The style to use for the text.
textAlignTextAlignHow the text should be aligned. Defaults to TextAlign.start.
textAlignVerticalStacTextAlignVertical?How the text should be aligned vertically.
textDirectionTextDirection?The direction of the text.
readOnlyboolWhether the text form field is read-only. Defaults to false.
showCursorbool?Whether to show the cursor.
autofocusboolWhether the text form field should focus itself if nothing else is already focused. Defaults to false.
obscuringCharacterStringThe character to use for obscuring text. Defaults to •.
maxLinesint?The maximum number of lines for the text.
minLinesint?The minimum number of lines for the text.
maxLengthint?The maximum number of characters for the text.
obscureTextbool?Whether to obscure the text.
autocorrectboolWhether to enable autocorrect. Defaults to true.
smartDashesTypeSmartDashesType?The type of smart dashes to use.
smartQuotesTypeSmartQuotesType?The type of smart quotes to use.
maxLengthEnforcementMaxLengthEnforcement?How the max length limit should be enforced.
expandsboolWhether the text form field should expand to fill its parent. Defaults to false.
keyboardAppearanceBrightness?The appearance of the keyboard.
scrollPaddingStacEdgeInsetsThe amount of space by which to inset the text form field when scrolling. Defaults to StacEdgeInsets(bottom: 20, top: 20, left: 20, right: 20).
restorationIdString?The restoration ID to save and restore the text form field's state.
enableIMEPersonalizedLearningboolWhether to enable personalized learning in the IME. Defaults to true.
enableSuggestionsboolWhether to enable suggestions. Defaults to true.
enabledbool?Whether the text form field is enabled.
cursorWidthdoubleThe width of the cursor. Defaults to 2.
cursorHeightdouble?The height of the cursor.
cursorColorString?The color of the cursor.
hintTextString?The hint text to display.
autovalidateModeAutovalidateMode?The mode to use for autovalidation.
inputFormattersList<StacInputFormatter>The list of input formatters to apply to the text. Defaults to an empty list.
validatorRulesList<StacFormFieldValidator>The list of validator rules to apply to the text. Defaults to an empty list.

Example JSON​

{
"type": "textFormField",
"id": "email",
"autovalidateMode": "onUserInteraction",
"validatorRules": [
{
"rule": "isEmail",
"message": "Please enter a valid email"
}
],
"style": {
"fontSize": 16,
"fontWeight": "w400",
"height": 1.5
},
"decoration": {
"hintText": "Email",
"filled": true,
"fillColor": "#FFFFFF",
"border": {
"type": "outlineInputBorder",
"borderRadius": 8,
"color": "#24151D29"
}
}
}