TextArea constructor
const
TextArea({
- Key? key,
- Object groupId = EditableText,
- TextEditingController? controller,
- FocusNode? focusNode,
- BoxDecoration? decoration,
- EdgeInsetsGeometry? padding,
- Widget? placeholder,
- CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center,
- String? clearButtonSemanticLabel,
- TextInputType? keyboardType,
- TextInputAction? textInputAction,
- TextCapitalization textCapitalization = TextCapitalization.none,
- TextStyle? style,
- StrutStyle? strutStyle,
- TextAlign textAlign = TextAlign.start,
- TextAlignVertical? textAlignVertical,
- TextDirection? textDirection,
- bool readOnly = false,
- bool? showCursor,
- bool autofocus = false,
- String obscuringCharacter = '•',
- bool obscureText = false,
- bool autocorrect = true,
- SmartDashesType smartDashesType = SmartDashesType.enabled,
- SmartQuotesType smartQuotesType = SmartQuotesType.enabled,
- bool enableSuggestions = true,
- int? maxLines = 1,
- int? minLines,
- bool expands = false,
- int? maxLength,
- MaxLengthEnforcement? maxLengthEnforcement,
- ValueChanged<
String> ? onChanged, - VoidCallback? onEditingComplete,
- ValueChanged<
String> ? onSubmitted, - TapRegionCallback? onTapOutside,
- TapRegionCallback? onTapUpOutside,
- List<
TextInputFormatter> ? inputFormatters, - bool enabled = true,
- double cursorWidth = 2.0,
- double? cursorHeight,
- Radius cursorRadius = const Radius.circular(2.0),
- bool cursorOpacityAnimates = true,
- Color? cursorColor,
- BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight,
- BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight,
- Brightness? keyboardAppearance,
- EdgeInsets scrollPadding = const EdgeInsets.all(20.0),
- bool enableInteractiveSelection = true,
- TextSelectionControls? selectionControls,
- DragStartBehavior dragStartBehavior = DragStartBehavior.start,
- ScrollController? scrollController,
- ScrollPhysics? scrollPhysics,
- GestureTapCallback? onTap,
- Iterable<
String> ? autofillHints = const [], - Clip clipBehavior = Clip.hardEdge,
- String? restorationId,
- bool stylusHandwritingEnabled = EditableText.defaultStylusHandwritingEnabled,
- bool enableIMEPersonalizedLearning = true,
- ContentInsertionConfiguration? contentInsertionConfiguration,
- EditableTextContextMenuBuilder? contextMenuBuilder,
- String? initialValue,
- String? hintText,
- Border? border,
- BorderRadiusGeometry? borderRadius,
- bool? filled,
- WidgetStatesController? statesController,
- TextMagnifierConfiguration? magnifierConfiguration,
- SpellCheckConfiguration? spellCheckConfiguration,
- UndoHistoryController? undoController,
- List<
InputFeature> features = const [], - List<
TextInputFormatter> ? submitFormatters = const [], - bool skipInputFeatureFocusTraversal = false,
- bool expandableHeight = false,
- bool expandableWidth = false,
- double initialHeight = 100,
- double initialWidth = double.infinity,
- ValueChanged<
double> ? onHeightChanged, - ValueChanged<
double> ? onWidthChanged, - double minWidth = 100,
- double minHeight = 100,
- double maxWidth = double.infinity,
- double maxHeight = double.infinity,
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,
super.groupId,
super.controller,
super.focusNode,
super.decoration,
super.padding,
super.placeholder,
super.crossAxisAlignment,
super.clearButtonSemanticLabel,
super.keyboardType,
super.textInputAction,
super.textCapitalization,
super.style,
super.strutStyle,
super.textAlign,
super.textAlignVertical,
super.textDirection,
super.readOnly,
super.showCursor,
super.autofocus,
super.obscuringCharacter,
super.obscureText,
super.autocorrect,
super.smartDashesType,
super.smartQuotesType,
super.enableSuggestions,
super.maxLines,
super.minLines,
super.expands,
super.maxLength,
super.maxLengthEnforcement,
super.onChanged,
super.onEditingComplete,
super.onSubmitted,
super.onTapOutside,
super.onTapUpOutside,
super.inputFormatters,
super.enabled,
super.cursorWidth,
super.cursorHeight,
super.cursorRadius,
super.cursorOpacityAnimates,
super.cursorColor,
super.selectionHeightStyle,
super.selectionWidthStyle,
super.keyboardAppearance,
super.scrollPadding,
super.enableInteractiveSelection,
super.selectionControls,
super.dragStartBehavior,
super.scrollController,
super.scrollPhysics,
super.onTap,
super.autofillHints,
super.clipBehavior,
super.restorationId,
super.stylusHandwritingEnabled,
super.enableIMEPersonalizedLearning,
super.contentInsertionConfiguration,
super.contextMenuBuilder,
super.initialValue,
super.hintText,
super.border,
super.borderRadius,
super.filled,
super.statesController,
super.magnifierConfiguration,
super.spellCheckConfiguration,
super.undoController,
super.features,
super.submitFormatters,
super.skipInputFeatureFocusTraversal,
this.expandableHeight = false,
this.expandableWidth = false,
this.initialHeight = 100,
this.initialWidth = double.infinity,
this.onHeightChanged,
this.onWidthChanged,
this.minWidth = 100,
this.minHeight = 100,
this.maxWidth = double.infinity,
this.maxHeight = double.infinity,
});