TextInputStatefulWidget constructor

const TextInputStatefulWidget({
  1. Key? key,
  2. Object groupId = EditableText,
  3. TextEditingController? controller,
  4. FocusNode? focusNode,
  5. BoxDecoration? decoration,
  6. EdgeInsetsGeometry? padding,
  7. Widget? placeholder,
  8. CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
  9. String? clearButtonSemanticLabel,
  10. TextInputType? keyboardType,
  11. TextInputAction? textInputAction,
  12. TextCapitalization textCapitalization = TextCapitalization.none,
  13. TextStyle? style,
  14. StrutStyle? strutStyle,
  15. TextAlign textAlign = TextAlign.start,
  16. TextAlignVertical? textAlignVertical,
  17. TextDirection? textDirection,
  18. bool readOnly = false,
  19. bool? showCursor,
  20. bool autofocus = false,
  21. String obscuringCharacter = '•',
  22. bool obscureText = false,
  23. bool autocorrect = true,
  24. SmartDashesType smartDashesType = SmartDashesType.enabled,
  25. SmartQuotesType smartQuotesType = SmartQuotesType.enabled,
  26. bool enableSuggestions = true,
  27. int? maxLines = 1,
  28. int? minLines,
  29. bool expands = false,
  30. int? maxLength,
  31. MaxLengthEnforcement? maxLengthEnforcement,
  32. ValueChanged<String>? onChanged,
  33. VoidCallback? onEditingComplete,
  34. ValueChanged<String>? onSubmitted,
  35. TapRegionCallback? onTapOutside,
  36. TapRegionCallback? onTapUpOutside,
  37. List<TextInputFormatter>? inputFormatters,
  38. bool enabled = true,
  39. double cursorWidth = 2.0,
  40. double? cursorHeight,
  41. Radius cursorRadius = const Radius.circular(2.0),
  42. bool cursorOpacityAnimates = true,
  43. Color? cursorColor,
  44. BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
  45. BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
  46. Brightness? keyboardAppearance,
  47. EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
  48. bool enableInteractiveSelection = true,
  49. TextSelectionControls? selectionControls,
  50. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  51. ScrollController? scrollController,
  52. ScrollPhysics? scrollPhysics,
  53. GestureTapCallback? onTap,
  54. Iterable<String>? autofillHints = const [],
  55. Clip clipBehavior = Clip.hardEdge,
  56. String? restorationId,
  57. bool stylusHandwritingEnabled = EditableText.defaultStylusHandwritingEnabled,
  58. bool enableIMEPersonalizedLearning = true,
  59. ContentInsertionConfiguration? contentInsertionConfiguration,
  60. EditableTextContextMenuBuilder? contextMenuBuilder,
  61. String? initialValue,
  62. String? hintText,
  63. Border? border,
  64. BorderRadiusGeometry? borderRadius,
  65. bool? filled,
  66. WidgetStatesController? statesController,
  67. TextMagnifierConfiguration? magnifierConfiguration,
  68. SpellCheckConfiguration? spellCheckConfiguration,
  69. UndoHistoryController? undoController,
  70. List<InputFeature> features = const [],
  71. List<TextInputFormatter>? submitFormatters = const [],
  72. bool skipInputFeatureFocusTraversal = false,
})

Creates a stateful text input widget with comprehensive configuration options.

This constructor accepts all properties defined in the TextInput mixin, providing extensive control over text input behavior, appearance, and interactions.

Most parameters mirror Flutter's EditableText widget while adding custom features like input features, decorations, and form integration.

Key parameters include:

  • controller: Text editing controller, created automatically if null
  • focusNode: Focus node for keyboard interaction
  • decoration: Box decoration for the input container
  • padding: Inner padding around the text field
  • placeholder: Widget shown when field is empty
  • enabled: Whether input accepts user interaction, defaults to true
  • readOnly: Whether text can be edited, defaults to false
  • obscureText: Whether to hide input (for passwords), defaults to false
  • maxLines: Maximum number of lines, defaults to 1
  • features: List of input features (e.g., clear button, character count)

See TextInput mixin documentation for full parameter details.

Implementation

const TextInputStatefulWidget({
  super.key,
  this.groupId = EditableText,
  this.controller,
  this.focusNode,
  this.decoration,
  this.padding,
  this.placeholder,
  this.crossAxisAlignment = CrossAxisAlignment.center,
  this.clearButtonSemanticLabel,
  this.keyboardType,
  this.textInputAction,
  this.textCapitalization = TextCapitalization.none,
  this.style,
  this.strutStyle,
  this.textAlign = TextAlign.start,
  this.textAlignVertical,
  this.textDirection,
  this.readOnly = false,
  this.showCursor,
  this.autofocus = false,
  this.obscuringCharacter = '•',
  this.obscureText = false,
  this.autocorrect = true,
  this.smartDashesType = SmartDashesType.enabled,
  this.smartQuotesType = SmartQuotesType.enabled,
  this.enableSuggestions = true,
  this.maxLines = 1,
  this.minLines,
  this.expands = false,
  this.maxLength,
  this.maxLengthEnforcement,
  this.onChanged,
  this.onEditingComplete,
  this.onSubmitted,
  this.onTapOutside,
  this.onTapUpOutside,
  this.inputFormatters,
  this.enabled = true,
  this.cursorWidth = 2.0,
  this.cursorHeight,
  this.cursorRadius = const Radius.circular(2.0),
  this.cursorOpacityAnimates = true,
  this.cursorColor,
  this.selectionHeightStyle = ui.BoxHeightStyle.tight,
  this.selectionWidthStyle = ui.BoxWidthStyle.tight,
  this.keyboardAppearance,
  this.scrollPadding = const EdgeInsets.all(20.0),
  this.enableInteractiveSelection = true,
  this.selectionControls,
  this.dragStartBehavior = DragStartBehavior.start,
  this.scrollController,
  this.scrollPhysics,
  this.onTap,
  this.autofillHints = const [],
  this.clipBehavior = Clip.hardEdge,
  this.restorationId,
  this.stylusHandwritingEnabled =
      EditableText.defaultStylusHandwritingEnabled,
  this.enableIMEPersonalizedLearning = true,
  this.contentInsertionConfiguration,
  this.contextMenuBuilder,
  this.initialValue,
  this.hintText,
  this.border,
  this.borderRadius,
  this.filled,
  this.statesController,
  this.magnifierConfiguration,
  this.spellCheckConfiguration,
  this.undoController,
  this.features = const [],
  this.submitFormatters = const [],
  this.skipInputFeatureFocusTraversal = false,
});