ShadTextarea class
A customizable multiline textarea widget with adjustable height and optional resizing grip.
The ShadTextarea widget builds on ShadInput to provide a rich, multiline text input experience with support for theming, placeholder content, and resize interaction.
It integrates with ShadTheme for consistent appearance, and includes properties for min/max height, editable behavior, styling, and decoration.
The field grows or shrinks based on content height (number of lines), and supports user-driven resizing using a drag handle, if resizable is enabled.
See also:
- resizeHandleBuilder, for customizing the drag handle
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- ShadTextarea
- Available extensions
Constructors
-
ShadTextarea({Key? key, String? initialValue, TextEditingController? controller, FocusNode? focusNode, Widget? placeholder, ShadDecoration? decoration, UndoHistoryController? undoController, ValueChanged<
String> ? onChanged, VoidCallback? onEditingComplete, ValueChanged<String> ? onSubmitted, AppPrivateCommandCallback? onAppPrivateCommand, TextStyle? style, StrutStyle? strutStyle, TextAlign textAlign = TextAlign.start, TextDirection? textDirection, bool? showCursor, bool autofocus = false, bool enabled = true, double? cursorWidth, double? cursorHeight, Radius? cursorRadius, bool? cursorOpacityAnimates, Color? cursorColor, BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight, BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight, Brightness? keyboardAppearance, EdgeInsets scrollPadding = const EdgeInsets.all(20), DragStartBehavior dragStartBehavior = DragStartBehavior.start, bool? enableInteractiveSelection, TextSelectionControls? selectionControls, GestureTapCallback? onPressed, bool onPressedAlwaysCalled = false, TapRegionCallback? onPressedOutside, MouseCursor? mouseCursor, ScrollController? scrollController, ScrollPhysics? scrollPhysics, ContentInsertionConfiguration? contentInsertionConfiguration, Clip clipBehavior = Clip.hardEdge, String? restorationId, bool scribbleEnabled = true, bool enableIMEPersonalizedLearning = true, EditableTextContextMenuBuilder? contextMenuBuilder, SpellCheckConfiguration? spellCheckConfiguration, TextMagnifierConfiguration magnifierConfiguration = TextMagnifierConfiguration.disabled, Color? selectionColor, EdgeInsetsGeometry? padding, MainAxisAlignment? mainAxisAlignment, CrossAxisAlignment? crossAxisAlignment, AlignmentGeometry? alignment, TextStyle? placeholderStyle, AlignmentGeometry? placeholderAlignment, EdgeInsetsGeometry? inputPadding, double? gap, BoxConstraints? constraints, bool stylusHandwritingEnabled = EditableText.defaultStylusHandwritingEnabled, Object? groupId, bool readOnly = false, int? maxLength, double minHeight = 80, double maxHeight = 500, bool resizable = true, ValueChanged<double> ? onHeightChanged, WidgetBuilder? resizeHandleBuilder, EdgeInsetsGeometry? scrollbarPadding, WidgetBuilder? keyboardToolbarBuilder, Widget? top, Widget? bottom, Widget? leading, Widget? trailing, ValueChanged<int> ? onLineCountChange, double? verticalGap, bool? useBrowserContextMenu, ValueChanged<List< ? onPasteFiles, ValueChanged<ShadClipboardItem> >Object> ? onPasteFilesError}) -
const
Properties
- alignment → AlignmentGeometry?
-
Alignment for the input field.
Defaults to Alignment.topLeft.
final
- autofocus → bool
-
Whether the field should focus itself
automatically when the widget is built.
final
- bottom → Widget?
-
The widget displayed below the input field.
final
- clipBehavior → Clip
-
Clip behavior of the textarea's content. Default is Clip.hardEdge.
final
- constraints → BoxConstraints?
-
Constraints to control layout of the field (e.g. minHeight).
final
- contentInsertionConfiguration → ContentInsertionConfiguration?
-
Platform-specific configuration for handling content insertion.
final
- contextMenuBuilder → EditableTextContextMenuBuilder?
-
Builds the context menu that appears
when text is long-pressed or selected.
final
- controller → TextEditingController?
-
Controls the text being edited. If null, an internal controller is created
and initialized with initialValue.
final
- crossAxisAlignment → CrossAxisAlignment?
-
Layout alignment along the vertical axis of the row.
final
- cursorColor → Color?
-
Color of the cursor.
final
- cursorHeight → double?
-
Height of the cursor.
final
- cursorOpacityAnimates → bool?
-
Whether the cursor opacity should animate.
final
- cursorRadius → Radius?
-
Radius of the cursor for rounded corners.
final
- cursorWidth → double?
-
Width of the cursor.
final
- decoration → ShadDecoration?
-
Optional visual decoration for the textarea.
Merged with the theme’s default decoration if provided.
final
- dragStartBehavior → DragStartBehavior
-
The kind of drag behavior this widget uses for text selection.
final
- enabled → bool
-
Whether the textarea is enabled and can be interacted with.
final
- enableIMEPersonalizedLearning → bool
-
Enables IME (Input Method Editor) to personalize learning.
final
- enableInteractiveSelection → bool
-
Whether to allow interactive text selection.
final
- focusNode → FocusNode?
-
Defines the keyboard focus for this widget.
If null, one will be created automatically.
final
- gap → double?
-
Horizontal spacing between text and any leading/trailing elements.
final
- groupId → Object?
-
ID used to group text fields for focus/interaction.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialValue → String?
-
The initial text value of the textarea.
Used if controller is null; cannot be used with controller.
final
- inputPadding → EdgeInsetsGeometry?
-
Inner padding between text and decoration inside the textarea.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardAppearance → Brightness?
-
Appearance (light/dark) for the keyboard.
final
- keyboardToolbarBuilder → WidgetBuilder?
-
A builder function that returns the toolbar widget.
final
- leading → Widget?
-
The widget displayed before the input field.
Typically an icon or small graphic.
final
- magnifierConfiguration → TextMagnifierConfiguration
-
Configuration for the text magnifier shown during selection.
final
- mainAxisAlignment → MainAxisAlignment?
-
Layout alignment along the horizontal axis (e.g. leading, text, trailing).
final
- maxHeight → double
-
The maximum height of the textarea (default is 500).
final
- maxLength → int?
-
The maximum length of the textarea.
Defaults to null (no limit).
final
- minHeight → double
-
The minimum height of the textarea (default is 80).
final
- mouseCursor → MouseCursor?
-
The mouse cursor to use when hovering over this widget.
final
- onAppPrivateCommand → AppPrivateCommandCallback?
-
Called for platform-specific app commands sent to the input field.
final
-
onChanged
→ ValueChanged<
String> ? -
Called when the text being edited changes.
final
- onEditingComplete → VoidCallback?
-
Called when the user indicates they are done editing the text.
final
-
onHeightChanged
→ ValueChanged<
double> ? -
Callback triggered whenever the textarea is resized.
final
-
onLineCountChange
→ ValueChanged<
int> ? -
The callback that is called when the line count changes.
The current line count is passed as an argument.
final
-
onPasteFiles
→ ValueChanged<
List< ?ShadClipboardItem> > -
Called when files are pasted from the clipboard on web.
final
-
onPasteFilesError
→ ValueChanged<
Object> ? -
Called when an error occurs while extracting files from the clipboard.
final
- onPressed → VoidCallback?
-
Called when the user taps the textarea.
final
- onPressedAlwaysCalled → bool
-
Whether onPressed is called even when text is selected.
final
- onPressedOutside → TapRegionCallback?
-
Called when a pointer tap happens outside this widget.
final
-
onSubmitted
→ ValueChanged<
String> ? -
Called when the user submits the text (e.g. presses "done").
final
- padding → EdgeInsetsGeometry?
-
Padding around the field.
This is outer padding including borders and input.
final
- placeholder → Widget?
-
The widget shown when the textarea is empty. Typically a Text widget.
final
- placeholderAlignment → AlignmentGeometry?
-
Alignment for the placeholder inside the field.
final
- placeholderStyle → TextStyle?
-
The text style to use for the placeholder.
If not specified, uses the theme's muted style.
final
- readOnly → bool
-
Whether the text field is read-only.
final
- resizable → bool
-
Whether the textarea can be resized by the user (default is true).
final
- resizeHandleBuilder → WidgetBuilder?
-
Allows customizing the resize handle (shown at bottom-right).
final
- restorationId → String?
-
Restoration ID used to save the textarea’s state.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scribbleEnabled → bool
-
Enables or disables Apple Pencil Scribble input on iPad.
final
- scrollbarPadding → EdgeInsetsGeometry?
-
The padding around the scrollbar.
final
- scrollController → ScrollController?
-
Optional controller for managing scroll position.
final
- scrollPadding → EdgeInsets
-
Insets to apply to the input when it's scrolled into view.
final
- scrollPhysics → ScrollPhysics?
-
The physics applied to the textarea's scroll behavior.
final
- selectionColor → Color?
-
Color used to highlight selected text when focused.
final
- selectionControls → TextSelectionControls?
-
Controls for displaying custom selection handles.
final
- selectionHeightStyle → BoxHeightStyle
-
Style used to calculate height of text selection highlight.
final
- selectionWidthStyle → BoxWidthStyle
-
Style used to calculate width of text selection highlight.
final
- showCursor → bool?
-
Whether to show the cursor.
final
- spellCheckConfiguration → SpellCheckConfiguration?
-
Configuration for enabling spell check support.
final
- strutStyle → StrutStyle?
-
The strut style used to determine the line height.
final
- style → TextStyle?
-
The text style used for the input text inside the textarea.
final
- stylusHandwritingEnabled → bool
-
Enables handwriting input using a stylus on supported platforms.
final
- textAlign → TextAlign
-
How the text inside the textarea is aligned horizontally.
final
- textDirection → TextDirection?
-
The direction of the text. Defaults to the inherited direction.
final
- top → Widget?
-
The widget displayed above the input field.
final
- trailing → Widget?
-
The widget displayed after the input field.
Typically an icon or small graphic.
final
- undoController → UndoHistoryController?
-
Optional controller for undo/redo functionality inside the text field.
final
- useBrowserContextMenu → bool?
-
Whether to use the browser's native context menu on web.
final
- verticalGap → double?
-
The gap between the input field and its top/bottom widgets.
final
Methods
-
animate(
{Key? key, List< Effect> ? effects, AnimateCallback? onInit, AnimateCallback? onPlay, AnimateCallback? onComplete, bool? autoPlay, Duration? delay, AnimationController? controller, Adapter? adapter, double? target, double? value}) → Animate -
Available on Widget, provided by the AnimateWidgetExtensions extension
Wraps the target Widget in an Animate instance, and returns the instance for chaining calls. Ex.myWidget.animate()is equivalent toAnimate(child: myWidget). -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< ShadTextarea> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
positionedWith(
ShadPosition position) → Widget -
Available on Widget, provided by the PositionedExt extension
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited