TxTextFormField constructor

TxTextFormField({
  1. bool? clearable,
  2. Key? key,
  3. FormFieldSetter<String>? onSaved,
  4. FormFieldValidator<String>? validator,
  5. bool? enabled,
  6. AutovalidateMode? autovalidateMode = AutovalidateMode.onUserInteraction,
  7. String? restorationId,
  8. InputDecoration? decoration,
  9. ValueChanged<String?>? onChanged,
  10. bool? required,
  11. String? initialValue,
  12. FocusNode? focusNode,
  13. String? hintText,
  14. TextAlign? textAlign,
  15. bool? bordered,
  16. TextEditingController? controller,
  17. UndoHistoryController? undoController,
  18. TextInputType? keyboardType,
  19. TextInputAction? textInputAction,
  20. TextCapitalization? textCapitalization,
  21. TextStyle? style,
  22. StrutStyle? strutStyle,
  23. TextAlignVertical? textAlignVertical,
  24. TextDirection? textDirection,
  25. bool? readOnly,
  26. bool? showCursor,
  27. bool? autofocus,
  28. MaterialStatesController? statesController,
  29. String? obscuringCharacter,
  30. bool? obscureText,
  31. bool? autocorrect,
  32. SmartDashesType? smartDashesType,
  33. SmartQuotesType? smartQuotesType,
  34. bool? enableSuggestions,
  35. int? maxLines,
  36. int? minLines,
  37. bool? expands,
  38. int? maxLength,
  39. MaxLengthEnforcement? maxLengthEnforcement,
  40. VoidCallback? onEditingComplete,
  41. ValueChanged<String>? onFieldSubmitted,
  42. AppPrivateCommandCallback? onAppPrivateCommand,
  43. List<TextInputFormatter>? inputFormatters,
  44. double? cursorWidth,
  45. double? cursorHeight,
  46. Radius? cursorRadius,
  47. bool? cursorOpacityAnimates,
  48. Color? cursorColor,
  49. Color? cursorErrorColor,
  50. BoxHeightStyle? selectionHeightStyle,
  51. BoxWidthStyle? selectionWidthStyle,
  52. Brightness? keyboardAppearance,
  53. EdgeInsets? scrollPadding,
  54. DragStartBehavior? dragStartBehavior,
  55. bool? enableInteractiveSelection,
  56. TextSelectionControls? selectionControls,
  57. ValueChanged<TxFormFieldState<String>>? onFieldTap,
  58. GestureTapCallback? onTap,
  59. bool? onTapAlwaysCalled,
  60. TapRegionCallback? onTapOutside,
  61. MouseCursor? mouseCursor,
  62. InputCounterWidgetBuilder? buildCounter,
  63. ScrollController? scrollController,
  64. ScrollPhysics? scrollPhysics,
  65. Iterable<String>? autofillHints,
  66. ContentInsertionConfiguration? contentInsertionConfiguration,
  67. Clip? clipBehavior,
  68. bool? scribbleEnabled,
  69. bool? enableIMEPersonalizedLearning,
  70. EditableTextContextMenuBuilder? contextMenuBuilder,
  71. bool? canRequestFocus,
  72. SpellCheckConfiguration? spellCheckConfiguration,
  73. TextMagnifierConfiguration? magnifierConfiguration,
  74. Widget? label,
  75. String? labelText,
  76. TextAlign? labelTextAlign,
  77. TextOverflow? labelOverflow,
  78. EdgeInsetsGeometry? padding,
  79. FieldActionsBuilder<String>? actionsBuilder,
  80. TextStyle? labelStyle,
  81. double? horizontalGap,
  82. Color? tileColor,
  83. Axis? layoutDirection,
  84. TxFormFieldBuilder<String>? trailingBuilder,
  85. Widget? leading,
  86. VisualDensity? visualDensity,
  87. ShapeBorder? shape,
  88. Color? iconColor,
  89. Color? textColor,
  90. TextStyle? leadingAndTrailingTextStyle,
  91. double? minLeadingWidth,
  92. double? minLabelWidth,
  93. double? minVerticalPadding,
  94. bool? dense,
  95. bool? colon,
  96. Color? focusColor,
})

Implementation

TxTextFormField({
  super.clearable,
  super.key,
  super.onSaved,
  FormFieldValidator<String>? validator,
  super.enabled,
  super.autovalidateMode,
  super.restorationId,
  super.decoration,
  super.onChanged,
  super.required,
  super.initialValue,
  super.focusNode,
  String? hintText,
  super.textAlign,
  super.bordered,
  super.controller,
  super.undoController,
  super.keyboardType,
  super.textInputAction,
  super.textCapitalization,
  super.style,
  super.strutStyle,
  super.textAlignVertical,
  super.textDirection,
  super.readOnly,
  super.showCursor,
  super.autofocus,
  super.statesController,
  super.obscuringCharacter,
  super.obscureText,
  super.autocorrect,
  super.smartDashesType,
  super.smartQuotesType,
  super.enableSuggestions,
  super.maxLines,
  super.minLines,
  super.expands,
  super.maxLength,
  super.maxLengthEnforcement,
  super.onEditingComplete,
  super.onFieldSubmitted,
  super.onAppPrivateCommand,
  super.inputFormatters,
  super.cursorWidth,
  super.cursorHeight,
  super.cursorRadius,
  super.cursorOpacityAnimates,
  super.cursorColor,
  super.cursorErrorColor,
  super.selectionHeightStyle,
  super.selectionWidthStyle,
  super.keyboardAppearance,
  super.scrollPadding,
  super.dragStartBehavior,
  super.enableInteractiveSelection,
  super.selectionControls,
  super.onFieldTap,
  super.onTap,
  super.onTapAlwaysCalled,
  super.onTapOutside,
  super.mouseCursor,
  super.buildCounter,
  super.scrollController,
  super.scrollPhysics,
  super.autofillHints,
  super.contentInsertionConfiguration,
  super.clipBehavior,
  super.scribbleEnabled,
  super.enableIMEPersonalizedLearning,
  super.contextMenuBuilder,
  super.canRequestFocus,
  super.spellCheckConfiguration,
  super.magnifierConfiguration,
  super.label,
  super.labelText,
  super.labelTextAlign,
  super.labelOverflow,
  super.padding,
  super.actionsBuilder,
  super.labelStyle,
  super.horizontalGap,
  super.tileColor,
  super.layoutDirection,
  super.trailingBuilder,
  super.leading,
  super.visualDensity,
  super.shape,
  super.iconColor,
  super.textColor,
  super.leadingAndTrailingTextStyle,
  super.minLeadingWidth,
  super.minLabelWidth,
  super.minVerticalPadding,
  super.dense,
  super.colon,
  super.focusColor,
}) : super(
        displayTextMapper: (context, val) => val,
        validator: (value) {
          if (required == true && (value == null || value.isEmpty)) {
            return '请输入';
          }

          if (validator != null) {
            return validator(value);
          }
          return null;
        },
        isEmpty: (val) => val.isEmpty,
        hintText: readOnly == true ? null : hintText ?? '请输入',
      );