StacTextField class

A Stac model representing Flutter's TextField widget.

A material design text field that allows users to enter and edit text. Can be configured for single-line or multi-line input, different keyboard types, obscured input for passwords, and more. Visuals like label, hint, prefix/suffix can be provided via decoration.

{@tool snippet} Dart Example:

StacTextField(
  initialValue: 'John Doe',
  keyboardType: StacTextInputType.text,
  textInputAction: StacTextInputAction.done,
  decoration: StacInputDecoration(
    labelText: 'Name',
    hintText: 'Enter your full name',
  ),
)

{@end-tool}

{@tool snippet} JSON Example:

{
  "type": "textField",
  "initialValue": "John Doe",
  "keyboardType": "text",
  "textInputAction": "done",
  "decoration": {
    "labelText": "Name",
    "hintText": "Enter your full name"
  },
  "autofillHints": ["name"]
}

{@end-tool}

See also:

Inheritance
Annotations
  • @JsonSerializable(explicitToJson: true)

Constructors

StacTextField.new({String? initialValue, StacInputDecoration? decoration, StacTextInputType? keyboardType, StacTextInputAction? textInputAction, StacTextCapitalization? textCapitalization, StacTextStyle? style, StacTextAlign? textAlign, StacTextDirection? textDirection, bool? readOnly, bool? showCursor, bool? autofocus, String? obscuringCharacter, bool? obscureText, bool? autocorrect, bool? enableSuggestions, int? maxLines, int? minLines, bool? expands, int? maxLength, bool? enabled, StacColor? cursorColor, double? cursorWidth, double? cursorHeight, StacEdgeInsets? scrollPadding, bool? enableInteractiveSelection, StacMouseCursor? mouseCursor, StacDragStartBehavior? dragStartBehavior, StacScrollPhysics? scrollPhysics, String? restorationId, StacClip? clipBehavior, List<String>? autofillHints, StacAction? onTap, StacAction? onChanged, StacAction? onEditingComplete, StacAction? onSubmitted})
Creates a text field widget with the specified properties.
const
StacTextField.fromJson(Map<String, dynamic> json)
Creates a StacTextField from a JSON map.
factory

Properties

autocorrect bool?
Whether to enable autocorrect. If null, Flutter's default applies.
final
autofillHints List<String>?
Autofill hint strings to help the platform identify expected input.
final
autofocus bool?
Whether this text field should focus itself if nothing else is already focused.
final
clipBehavior StacClip?
How to clip the text field's content. Defaults to Clip.hardEdge in Flutter.
final
cursorColor StacColor?
The color to use when painting the cursor.
final
cursorHeight double?
How tall the cursor will be. If null, Flutter's default applies.
final
cursorWidth double?
How thick the cursor will be. If null, Flutter's default applies.
final
decoration StacInputDecoration?
Visual decoration and labeling for the text field.
final
dragStartBehavior StacDragStartBehavior?
Determines the way that drag start behavior is handled. If null, Flutter's default applies.
final
enabled bool?
If false, the text field is disabled and will not respond to input. If null, Flutter's default applies (enabled).
final
enableInteractiveSelection bool?
Whether to allow the user to interactively select text in the field. If null, Flutter's default applies.
final
enableSuggestions bool?
Whether to show input suggestions as the user types. If null, Flutter's default applies.
final
expands bool?
Whether this widget's height is the sum of minLines and maxLines, or whether it should grow to fill its parent.
final
hashCode int
The hash code for this object.
no setterinherited
initialValue String?
Initial text to display in the field.
final
jsonData Map<String, dynamic>?
Raw JSON data for this widget
finalinherited
keyboardType StacTextInputType?
The type of keyboard to use for editing the text.
final
maxLength int?
The maximum number of characters to allow in the text field. If null, there is no enforced character limit.
final
maxLines int?
The maximum number of lines for the text to span, wrapping if necessary. If null, behaves as a single-line field unless expands or minLines imply otherwise.
final
minLines int?
The minimum number of lines to occupy. If null, Flutter's default applies.
final
mouseCursor StacMouseCursor?
The cursor for a mouse pointer when it enters or hovers over the field.
final
obscureText bool?
Whether to hide the text being edited (e.g., for passwords).
final
obscuringCharacter String?
Character used for obscuring text if obscureText is true. If null, Flutter's default obscuring character is used.
final
onChanged StacAction?
Called when the text changes.
final
onEditingComplete StacAction?
Called when the user indicates that they are done editing the text in the field (e.g., focus lost or explicit completion).
final
onSubmitted StacAction?
Called when the user indicates that they are done editing the text in the field submitted through the IME action.
final
onTap StacAction?
Called when the user taps on the field.
final
readOnly bool?
Whether the text can be changed. If false, the field is non-interactive/read-only.
final
restorationId String?
Restoration ID to save and restore state (e.g., selection, scroll offset).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scrollPadding StacEdgeInsets?
Padding inset used when ensuring the field is visible while scrolling.
final
scrollPhysics StacScrollPhysics?
How the embedded scroll view should respond to user input.
final
showCursor bool?
Whether to show the cursor. If null, Flutter decides based on focus and platform.
final
style StacTextStyle?
The style to use for the text being edited.
final
textAlign StacTextAlign?
How the text should be aligned horizontally.
final
textCapitalization StacTextCapitalization?
Configures how the platform keyboard will select an uppercase or lowercase keyboard. If null, Flutter's default behavior applies.
final
textDirection StacTextDirection?
The directionality of the text.
final
textInputAction StacTextInputAction?
The type of action button to use for the keyboard.
final
type String
Widget type identifier.
no setteroverride

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts this StacTextField instance to a JSON map.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited