TextField constructor
const
TextField({
- Key? key,
- Object groupId = EditableText,
- TextEditingController? controller,
- String? initialValue,
- FocusNode? focusNode,
- UndoHistoryController? undoController,
- 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 = defaultContextMenuBuilder,
- String? hintText,
- Border? border,
- BorderRadiusGeometry? borderRadius,
- bool? filled,
- WidgetStatesController? statesController,
- TextMagnifierConfiguration? magnifierConfiguration,
- SpellCheckConfiguration? spellCheckConfiguration,
- List<
InputFeature> features = const [], - List<
TextInputFormatter> ? submitFormatters = const [], - bool skipInputFeatureFocusTraversal = false,
- ValueChanged<
TapDragStartDetails> ? onDragSelectionStart, - ValueChanged<
TapDragUpdateDetails> ? onDragSelectionUpdate, - ValueChanged<
TapDragEndDetails> ? onDragSelectionEnd,
Creates a text input field widget.
A comprehensive text field implementation with support for various input types, validation, formatting, and interactive features. All parameters are forwarded to the parent TextInputStatefulWidget constructor.
This constructor provides extensive customization options matching Flutter's EditableText while adding custom features like input decorations, features, and form integration.
Example:
TextField(
controller: myController,
hintText: 'Enter text',
keyboardType: TextInputType.text,
maxLines: 3,
onChanged: (value) => print(value),
)
See TextInputStatefulWidget and TextInput for parameter details.
Implementation
const TextField({
super.key,
super.groupId,
super.controller,
super.initialValue,
super.focusNode,
super.undoController,
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 = defaultContextMenuBuilder,
super.hintText,
super.border,
super.borderRadius,
super.filled,
super.statesController,
super.magnifierConfiguration,
super.spellCheckConfiguration,
super.features,
super.submitFormatters,
super.skipInputFeatureFocusTraversal,
this.onDragSelectionStart,
this.onDragSelectionUpdate,
this.onDragSelectionEnd,
});