Skip to main content
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
idStringThe identifier for the text form field.
compareIdStringThe identifier to compare with another text form field.
decorationStacInputDecorationThe decoration to show around the text form field.
initialValueStringThe initial value of the text form field.
keyboardTypeStacTextInputTypeThe type of keyboard to use for editing the text.
textInputActionStacTextInputActionThe action button to use for the keyboard.
textCapitalizationStacTextCapitalizationHow the text should be capitalized. Defaults to TextCapitalization.none.
styleStacTextStyleThe style to use for the text.
textAlignStacTextAlignHow the text should be aligned. Defaults to TextAlign.start.
textAlignVerticalStacTextAlignVerticalHow the text should be aligned vertically.
textDirectionStacTextDirectionThe direction of the text.
readOnlyboolWhether the text form field is read-only. Defaults to false.
showCursorboolWhether 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 .
maxLinesintThe maximum number of lines for the text.
minLinesintThe minimum number of lines for the text.
maxLengthintThe maximum number of characters for the text.
obscureTextboolWhether to obscure the text.
autocorrectboolWhether to enable autocorrect. Defaults to true.
smartDashesTypeStacSmartDashesTypeThe type of smart dashes to use.
smartQuotesTypeStacSmartQuotesTypeThe type of smart quotes to use.
maxLengthEnforcementStacMaxLengthEnforcementHow the max length limit should be enforced.
expandsboolWhether the text form field should expand to fill its parent. Defaults to false.
keyboardAppearanceStacBrightnessThe 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).
restorationIdStringThe 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.
enabledboolWhether the text form field is enabled.
cursorWidthdoubleThe width of the cursor. Defaults to 2.
cursorHeightdoubleThe height of the cursor.
cursorColorStacColorThe color of the cursor.
hintTextStringThe hint text to display.
autovalidateModeStacAutovalidateModeThe 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

StacTextFormField(
  id: 'email',
  autovalidateMode: StacAutovalidateMode.onUserInteraction,
  validatorRules: [
    StacFormFieldValidator(rule: 'isEmail', message: 'Please enter a valid email'),
  ],
  style: StacTextStyle(fontSize: 16, fontWeight: StacFontWeight.w400, height: 1.5),
  decoration: StacInputDecoration(
    hintText: 'Email',
    filled: true,
    fillColor: StacColors.white,
    border: StacOutlineInputBorder(borderRadius: 8, color: '#24151D29'),
  ),
)