TextArea constructor
const
TextArea({
- Key? key,
- bool expandableHeight = false,
- bool expandableWidth = false,
- double initialHeight = 100,
- double initialWidth = double.infinity,
- ValueChanged<
double> ? onHeightChanged, - ValueChanged<
double> ? onWidthChanged, - TextEditingController? controller,
- bool? filled,
- Widget? placeholder,
- Border? border,
- Widget? leading,
- Widget? trailing,
- EdgeInsetsGeometry? padding,
- ValueChanged<
String> ? onSubmitted, - VoidCallback? onEditingComplete,
- FocusNode? focusNode,
- VoidCallback? onTap,
- bool enabled = true,
- bool readOnly = false,
- bool obscureText = false,
- String obscuringCharacter = '•',
- String? initialValue,
- int? maxLength,
- MaxLengthEnforcement? maxLengthEnforcement,
- BorderRadiusGeometry? borderRadius,
- TextAlign textAlign = TextAlign.start,
- double minWidth = 100,
- double minHeight = 100,
- double maxWidth = double.infinity,
- double maxHeight = double.infinity,
- TextAlignVertical? textAlignVertical = TextAlignVertical.top,
- UndoHistoryController? undoController,
- ValueChanged<
String> ? onChanged, - Iterable<
String> ? autofillHints, - void onTapOutside(
- PointerDownEvent event
- List<
TextInputFormatter> ? inputFormatters, - TextStyle? style,
- EditableTextContextMenuBuilder? contextMenuBuilder,
- TextInputType? keyboardType,
- TextInputAction? textInputAction,
- Clip clipBehavior = Clip.hardEdge,
- 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 resizingexpandableWidth
(bool, default: false): Enable horizontal resizinginitialHeight
(double, default: 100): Starting height in pixelsinitialWidth
(double, default: double.infinity): Starting width in pixelsenabled
(bool, default: true): Whether the text area accepts inputreadOnly
(bool, default: false): Whether the text is read-onlyobscureText
(bool, default: false): Whether to hide the textobscuringCharacter
(String, default: '•'): Character for hiding texttextAlign
(TextAlign, default: TextAlign.start): Horizontal text alignmentminWidth
(double, default: 100): Minimum width constraintminHeight
(double, default: 100): Minimum height constraintmaxWidth
(double, default: double.infinity): Maximum width constraintmaxHeight
(double, default: double.infinity): Maximum height constrainttextAlignVertical
(TextAlignVertical, default: top): Vertical text alignmentclipBehavior
(Clip, default: Clip.hardEdge): Content clipping behaviorautofocus
(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,
});