TextArea constructor

const TextArea({
  1. Key? key,
  2. bool expandableHeight = false,
  3. bool expandableWidth = false,
  4. double initialHeight = 100,
  5. double initialWidth = double.infinity,
  6. ValueChanged<double>? onHeightChanged,
  7. ValueChanged<double>? onWidthChanged,
  8. TextEditingController? controller,
  9. bool? filled,
  10. Widget? placeholder,
  11. Border? border,
  12. Widget? leading,
  13. Widget? trailing,
  14. EdgeInsetsGeometry? padding,
  15. ValueChanged<String>? onSubmitted,
  16. VoidCallback? onEditingComplete,
  17. FocusNode? focusNode,
  18. VoidCallback? onTap,
  19. bool enabled = true,
  20. bool readOnly = false,
  21. bool obscureText = false,
  22. String obscuringCharacter = '•',
  23. String? initialValue,
  24. int? maxLength,
  25. MaxLengthEnforcement? maxLengthEnforcement,
  26. BorderRadiusGeometry? borderRadius,
  27. TextAlign textAlign = TextAlign.start,
  28. double minWidth = 100,
  29. double minHeight = 100,
  30. double maxWidth = double.infinity,
  31. double maxHeight = double.infinity,
  32. TextAlignVertical? textAlignVertical = TextAlignVertical.top,
  33. UndoHistoryController? undoController,
  34. ValueChanged<String>? onChanged,
  35. Iterable<String>? autofillHints,
  36. void onTapOutside(
    1. PointerDownEvent event
    )?,
  37. List<TextInputFormatter>? inputFormatters,
  38. TextStyle? style,
  39. EditableTextContextMenuBuilder? contextMenuBuilder,
  40. TextInputType? keyboardType,
  41. TextInputAction? textInputAction,
  42. Clip clipBehavior = Clip.hardEdge,
  43. bool autofocus = false,
})

Creates a TextArea with comprehensive configuration options.

The text area supports both controlled and uncontrolled modes. Use controller for controlled mode or initialValue for uncontrolled mode. The text area can be configured for resizing, styling, and various text input behaviors.

Parameters:

  • expandableHeight (bool, default: false): Enable vertical resizing
  • expandableWidth (bool, default: false): Enable horizontal resizing
  • initialHeight (double, default: 100): Starting height in pixels
  • initialWidth (double, default: double.infinity): Starting width in pixels
  • enabled (bool, default: true): Whether the text area accepts input
  • readOnly (bool, default: false): Whether the text is read-only
  • obscureText (bool, default: false): Whether to hide the text
  • obscuringCharacter (String, default: '•'): Character for hiding text
  • textAlign (TextAlign, default: TextAlign.start): Horizontal text alignment
  • minWidth (double, default: 100): Minimum width constraint
  • minHeight (double, default: 100): Minimum height constraint
  • maxWidth (double, default: double.infinity): Maximum width constraint
  • maxHeight (double, default: double.infinity): Maximum height constraint
  • textAlignVertical (TextAlignVertical, default: top): Vertical text alignment
  • clipBehavior (Clip, default: Clip.hardEdge): Content clipping behavior
  • autofocus (bool, default: false): Whether to auto-focus on creation

Example:

TextArea(
  placeholder: Text('Enter your message'),
  expandableHeight: true,
  minHeight: 100,
  maxHeight: 300,
  onChanged: (text) => _handleTextChange(text),
);

Implementation

const TextArea({
  super.key,
  this.expandableHeight = false,
  this.expandableWidth = false,
  this.initialHeight = 100,
  this.initialWidth = double.infinity,
  this.onHeightChanged,
  this.onWidthChanged,
  this.controller,
  this.filled,
  this.placeholder,
  this.border,
  this.leading,
  this.trailing,
  this.padding,
  this.onSubmitted,
  this.onEditingComplete,
  this.focusNode,
  this.onTap,
  this.enabled = true,
  this.readOnly = false,
  this.obscureText = false,
  this.obscuringCharacter = '•',
  this.initialValue,
  this.maxLength,
  this.maxLengthEnforcement,
  this.borderRadius,
  this.textAlign = TextAlign.start,
  this.minWidth = 100,
  this.minHeight = 100,
  this.maxWidth = double.infinity,
  this.maxHeight = double.infinity,
  this.textAlignVertical = TextAlignVertical.top,
  this.undoController,
  this.onChanged,
  this.autofillHints,
  this.onTapOutside,
  this.inputFormatters,
  this.style,
  this.contextMenuBuilder,
  this.keyboardType,
  this.textInputAction,
  this.clipBehavior = Clip.hardEdge,
  this.autofocus = false,
});