ShadInput class

A customizable text input field with optional leading and trailing widgets.

The ShadInput widget provides a styled text field with support for placeholders, leading/trailing decorations, and extensive text editing features. It integrates with ShadTheme for consistent styling and supports advanced interactions like selection, context menus, and autofill.

Inheritance
Available extensions

Constructors

ShadInput({Key? key, String? initialValue, Widget? placeholder, TextEditingController? controller, FocusNode? focusNode, ShadDecoration? decoration, UndoHistoryController? undoController, TextInputType? keyboardType, TextInputAction? textInputAction, TextCapitalization textCapitalization = TextCapitalization.none, TextStyle? style, StrutStyle? strutStyle, TextAlign textAlign = TextAlign.start, TextDirection? textDirection, bool readOnly = false, bool? showCursor, bool autofocus = false, String obscuringCharacter = '•', bool obscureText = false, bool autocorrect = true, SmartDashesType? smartDashesType, SmartQuotesType? smartQuotesType, bool enableSuggestions = true, int? maxLines = 1, int? minLines, bool expands = false, int? maxLength, MaxLengthEnforcement? maxLengthEnforcement, ValueChanged<String>? onChanged, VoidCallback? onEditingComplete, ValueChanged<String>? onSubmitted, AppPrivateCommandCallback? onAppPrivateCommand, List<TextInputFormatter>? inputFormatters, 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, Iterable<String>? autofillHints = const <String>[], 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, Widget? leading, Widget? trailing, MainAxisAlignment? mainAxisAlignment, CrossAxisAlignment? crossAxisAlignment, TextStyle? placeholderStyle, AlignmentGeometry? alignment, AlignmentGeometry? placeholderAlignment, EdgeInsetsGeometry? inputPadding, double? gap, BoxConstraints? constraints, bool stylusHandwritingEnabled = EditableText.defaultStylusHandwritingEnabled, Object? groupId, EdgeInsetsGeometry? scrollbarPadding, WidgetBuilder? keyboardToolbarBuilder, Widget? top, Widget? bottom, ValueChanged<int>? onLineCountChange, Size? editableTextSize, double? verticalGap, bool? useBrowserContextMenu, ValueChanged<List<ShadClipboardItem>>? onPasteFiles, ValueChanged<Object>? onPasteFilesError})
Creates a text input widget with customizable properties.
const

Properties

alignment AlignmentGeometry?
The alignment of the input field. Defaults to Alignment.topLeft if not specified.
final
autocorrect bool
Whether autocorrect is enabled for the input. Defaults to true.
final
autofillHints Iterable<String>?
Hints for autofill services to suggest values. Defaults to an empty list.
final
autofocus bool
Whether the input automatically receives focus when built. Defaults to false.
final
bottom Widget?
The widget displayed below the input field.
final
clipBehavior Clip
The clip behavior for the input’s content. Defaults to Clip.hardEdge.
final
constraints BoxConstraints?
The constraints of the input field.
final
contentInsertionConfiguration ContentInsertionConfiguration?
Configuration for content insertion (e.g., paste handling). Defaults to null, using default behavior.
final
contextMenuBuilder EditableTextContextMenuBuilder?
Custom builder for the context menu (e.g., copy/paste). Defaults to a simple toolbar with copy/cut/paste buttons styled with ShadTheme.
final
controller TextEditingController?
The controller for managing the text input’s value and selection. If null, an internal controller is created with initialValue.
final
crossAxisAlignment CrossAxisAlignment?
The cross axis alignment of the input’s row (vertical). Defaults to CrossAxisAlignment.center if not specified.
final
cursorColor Color?
The color of the cursor. Defaults to the theme’s primary color if not specified.
final
cursorHeight double?
The height of the cursor. Defaults to null, matching the text height.
final
cursorOpacityAnimates bool?
Whether the cursor opacity animates when blinking. Defaults to false, relying on EditableText default value.
final
cursorRadius Radius?
The radius of the cursor’s corners. Defaults to null (sharp edges).
final
cursorWidth double?
The width of the cursor. Defaults to 2.0 pixels.
final
decoration ShadDecoration?
The decoration applied to the input field. Merged with the theme’s default decoration if provided.
final
dragStartBehavior DragStartBehavior
The behavior for starting a drag gesture. Defaults to DragStartBehavior.start.
final
editableTextSize Size?
The size of the EditableText widget.
final
enabled bool
Whether the input is interactive. Defaults to true; if false, the input is disabled and visually dimmed.
final
enableIMEPersonalizedLearning bool
Whether the IME can use personalized learning data. Defaults to true.
final
enableInteractiveSelection bool
Whether interactive text selection is enabled. Defaults to true unless readOnly or obscureText is true.
final
enableSuggestions bool
Whether text suggestions are enabled for the input. Defaults to true.
final
expands bool
Whether the input expands to fill available vertical space. Defaults to false; requires maxLines and minLines to be null.
final
focusNode FocusNode?
The focus node for controlling focus behavior. If null, an internal focus node is created.
final
gap double?
The gap between the input field and its leading/trailing widgets. Defaults to 8 if not specified.
final
groupId Object?
The group identifier for the TextFieldTapRegion of this text field.
final
hashCode int
The hash code for this object.
no setterinherited
initialValue String?
The initial text value of the input. Used if controller is null; cannot be used with controller.
final
inputFormatters List<TextInputFormatter>?
The list of formatters to apply to the input text. Controls text transformation (e.g., masking, filtering).
final
inputPadding EdgeInsetsGeometry?
The padding around the editable text within the input field. Defaults to EdgeInsets.zero if not specified.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardAppearance Brightness?
The appearance (brightness) of the keyboard. Defaults to the theme’s brightness if not specified.
final
keyboardToolbarBuilder WidgetBuilder?
A builder function that returns the toolbar widget.
final
keyboardType TextInputType
The type of keyboard to display for the input. Defaults to TextInputType.text for single-line, TextInputType.multiline otherwise.
final
leading Widget?
The widget displayed before the input field. Typically an icon or small graphic.
final
magnifierConfiguration TextMagnifierConfiguration
Configuration for the text magnifier. Defaults to TextMagnifierConfiguration.disabled.
final
mainAxisAlignment MainAxisAlignment?
The main axis alignment of the input’s row (horizontal). Defaults to MainAxisAlignment.start if not specified.
final
maxLength int?
The maximum length of the input text. Defaults to null (no limit); enforced by maxLengthEnforcement.
final
maxLengthEnforcement MaxLengthEnforcement?
How the maxLength is enforced. Defaults to platform-specific behavior if not specified.
final
maxLines int?
The maximum number of lines the input can span. Defaults to 1; affects keyboardType.
final
minLines int?
The minimum number of lines the input should display. Defaults to null; must be less than or equal to maxLines.
final
mouseCursor MouseCursor?
The cursor displayed when hovering over the input. Defaults to WidgetStateMouseCursor.textable.
final
obscureText bool
Whether the input text is obscured (e.g., for passwords). Defaults to false; affects smartDashesType and smartQuotesType.
final
obscuringCharacter String
The character used to obscure text when obscureText is true. Defaults to '•'.
final
onAppPrivateCommand AppPrivateCommandCallback?
Callback for handling private app commands. Provides action and data for platform-specific features.
final
onChanged ValueChanged<String>?
Callback invoked when the input text changes. Provides the new text value.
final
onEditingComplete VoidCallback?
Callback invoked when editing is completed (e.g., via keyboard action). Does not provide the text value.
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?
Callback invoked when the input field is tapped. Useful for custom tap handling, e.g., in read-only mode.
final
onPressedAlwaysCalled bool
Whether onPressed is called even when selection is active. Defaults to false; if true, always triggers on tap.
final
onPressedOutside TapRegionCallback?
Callback invoked when tapping outside the input field. Useful for handling focus dismissal or other actions.
final
onSubmitted ValueChanged<String>?
Callback invoked when the user submits the input (e.g., pressing Enter). Provides the submitted text value.
final
padding EdgeInsetsGeometry?
The padding around the entire input, including decorations. Defaults to theme’s input padding if not specified.
final
placeholder Widget?
The widget displayed when the input is empty. Typically a Text widget, styled with placeholderStyle.
final
placeholderAlignment AlignmentGeometry?
The alignment of the placeholder within the input field. Defaults to Alignment.topLeft if not specified.
final
placeholderStyle TextStyle?
The text style for the placeholder when the input is empty. Defaults to the theme’s muted style if not specified.
final
readOnly bool
Whether the input is read-only. Defaults to false; if true, editing is disabled but selection may still be enabled.
final
restorationId String?
The ID for restoring the input’s state across sessions. Defaults to null (no restoration).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scribbleEnabled bool
Whether scribble (handwriting) input is enabled. Defaults to true.
final
scrollbarPadding EdgeInsetsGeometry?
The padding around the scrollbar.
final
scrollController ScrollController?
The controller for managing scrolling within the input. Defaults to null (no custom scrolling).
final
scrollPadding EdgeInsets
The padding applied around the input when scrolling to keep it visible. Defaults to EdgeInsets.all(20).
final
scrollPhysics ScrollPhysics?
The physics applied to scrolling within the input. Defaults to null, relying on platform defaults.
final
selectionColor Color?
The color of the text selection highlight. Defaults to the theme’s selection color when focused.
final
selectionControls TextSelectionControls?
Custom controls for text selection handles. Defaults to platform-specific controls if not specified.
final
selectionEnabled bool
Whether text selection is enabled, based on enableInteractiveSelection.
no setter
selectionHeightStyle BoxHeightStyle
The height style of the selection highlight. Defaults to ui.BoxHeightStyle.tight.
final
selectionWidthStyle BoxWidthStyle
The width style of the selection highlight. Defaults to ui.BoxWidthStyle.tight.
final
showCursor bool?
Whether to display the cursor in the input. Defaults to null, relying on Flutter’s default behavior.
final
smartDashesType SmartDashesType
The smart dashes behavior for the input. Defaults to enabled if not obscured, disabled if obscured.
final
smartQuotesType SmartQuotesType
The smart quotes behavior for the input. Defaults to enabled if not obscured, disabled if obscured.
final
spellCheckConfiguration SpellCheckConfiguration?
Configuration for spell checking in the input. Defaults to null (no spell checking).
final
strutStyle StrutStyle?
The strut style for controlling line spacing. Defaults to null, relying on the text style.
final
style TextStyle?
The text style for the input content. Defaults to the theme’s muted style with foreground color if not specified.
final
stylusHandwritingEnabled bool
Whether this input supports stylus handwriting, where the user can write directly on top of a field.
final
textAlign TextAlign
The horizontal alignment of the text within the input. Defaults to TextAlign.start.
final
textCapitalization TextCapitalization
The capitalization behavior for the input text. Defaults to TextCapitalization.none.
final
textDirection TextDirection?
The directionality of the text (e.g., LTR or RTL). Defaults to null, inheriting from the context.
final
textInputAction TextInputAction?
The action to perform when the user submits the input. Defaults to null, relying on platform behavior.
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?
The controller for managing undo/redo history. If null, undo functionality is not provided.
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 to Animate(child: myWidget).
createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<ShadInput>
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

Constants

noMaxLength → const int
A constant representing no maximum length for the input.