M3ETextField class
A Material 3 Expressive text field.
Comes in the filled and outlined variants. The label rests in the middle of an empty field and springs to the top when the field is focused or populated. Supports leading and trailing icons, prefix and suffix text, a placeholder, supporting or error text, a character counter, single-line, multi-line and text-area input, read-only and required fields, hover, focus, error and disabled states, and a keyboard focus ring.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- M3ETextField
Constructors
-
M3ETextField({TextEditingController? controller, FocusNode? focusNode, String? label, String? supportingText, String? errorText, Widget? leading, Widget? trailing, M3ETextFieldVariant variant = M3ETextFieldVariant.filled, bool obscureText = false, bool enabled = true, TextInputType? keyboardType, TextInputAction? textInputAction, List<
TextInputFormatter> ? inputFormatters, ValueChanged<String> ? onChanged, ValueChanged<String> ? onSubmitted, TapRegionCallback? onTapOutside, int? maxLines = 1, int? minLines, bool readOnly = false, bool autofocus = false, bool isRequired = false, String? prefixText, String? suffixText, String? prefixSemanticsLabel, String? suffixSemanticsLabel, String? placeholder, int? maxLength, bool? showCounter, M3ETextFieldCounterLabelBuilder counterSemanticsLabelBuilder = m3eTextFieldCounterLabel, bool supportingTextOnFocusOnly = false, bool showErrorIcon = true, bool showClearButton = false, bool showPasswordToggle = false, String clearButtonSemanticsLabel = 'Clear', String showPasswordSemanticsLabel = 'Show password', String hidePasswordSemanticsLabel = 'Hide password', String errorIconSemanticsLabel = 'Error', MouseCursor? mouseCursor, EditableTextContextMenuBuilder? contextMenuBuilder = m3eDefaultTextFieldContextMenuBuilder, TextCapitalization textCapitalization = TextCapitalization.none, TextAlign textAlign = TextAlign.start, int? density, M3ETextFieldSlotAlignment? iconAlignment, M3ETextFieldSlotAlignment? affixAlignment, M3ETextFieldTheme? theme, VoidCallback? onTap, VoidCallback? onEditingComplete, Key? key}) -
M3ETextField.
const
Properties
- affixAlignment → M3ETextFieldSlotAlignment?
-
Prefix/suffix text position in multi-line fields. Overrides
M3ETextFieldTheme.affixAlignment.
final
- autofocus → bool
-
autofocus.
final
- clearButtonSemanticsLabel → String
-
Clear button label.
final
- contextMenuBuilder → EditableTextContextMenuBuilder?
-
Selection context menu.
final
- controller → TextEditingController?
-
controller.
final
- counterSemanticsLabelBuilder → M3ETextFieldCounterLabelBuilder
-
Counter label for assistive tech.
final
- density → int?
-
Density from 0 down to -3; each step removes 4dp of height. Overrides
the theme density.
final
- enabled → bool
-
Disabled fields are faded and skipped by keyboard focus.
final
- errorIconSemanticsLabel → String
-
Error icon label.
final
- errorText → String?
-
Error text. Replaces supportingText and puts the field in error.
final
- focusNode → FocusNode?
-
focusNode.
final
- hasError → bool
-
The hasError.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hidePasswordSemanticsLabel → String
-
Password toggle label while the password is visible.
final
- iconAlignment → M3ETextFieldSlotAlignment?
-
Leading/trailing icon position in multi-line fields. Overrides
M3ETextFieldTheme.iconAlignment.
final
-
inputFormatters
→ List<
TextInputFormatter> ? -
inputFormatters.
final
- isRequired → bool
-
Adds an asterisk to the label, which is also read by assistive tech.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardType → TextInputType?
-
keyboardType.
final
- label → String?
-
Label text. It is also the field's accessibility label.
final
- leading → Widget?
-
Leading icon or 24dp image.
final
- maxLength → int?
-
Character limit. Enables the counter.
final
- maxLines → int?
-
Maximum visible lines. Above 1 the field grows as text wraps; null
lets it grow without a limit.
final
- minLines → int?
-
Minimum visible lines. Set equal to maxLines for a fixed-height text
area that scrolls vertically.
final
- mouseCursor → MouseCursor?
-
Pointer cursor. Default: text, or basic when disabled.
final
- obscureText → bool
-
Hides the input (single line only).
final
-
onChanged
→ ValueChanged<
String> ? -
Called whenever the controller notifies.
final
- onEditingComplete → VoidCallback?
-
onEditingComplete.
final
-
onSubmitted
→ ValueChanged<
String> ? -
onSubmitted.
final
- onTap → VoidCallback?
-
Called on each tap in the field.
final
- onTapOutside → TapRegionCallback?
-
Called on a tap outside the field. Default: unfocus.
final
- placeholder → String?
-
Placeholder shown while the field is focused and empty.
final
- prefixSemanticsLabel → String?
-
Accessibility label for prefixText, such as "Euro".
final
- prefixText → String?
-
Text before the input, such as a currency symbol.
final
- readOnly → bool
-
Shows text that cannot be edited, styled as a regular field.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showClearButton → bool
-
Shows a clear button while the field has text.
final
- showCounter → bool?
-
Shows the counter. Default: on when maxLength is set.
final
- showErrorIcon → bool
-
Shows an error icon in error when there is no trailing widget.
final
- showPasswordSemanticsLabel → String
-
Password toggle label while the password is hidden.
final
- showPasswordToggle → bool
-
Shows a show/hide password button. Starts from obscureText.
final
- suffixSemanticsLabel → String?
-
Accessibility label for suffixText, such as "At gmail dot com".
final
- suffixText → String?
-
Text after the input, such as a unit or email domain.
final
- supportingText → String?
-
Supporting text below the field.
final
- supportingTextOnFocusOnly → bool
-
Shows supportingText only while the field is focused.
final
- textAlign → TextAlign
-
textAlign.
final
- textCapitalization → TextCapitalization
-
textCapitalization.
final
- textInputAction → TextInputAction?
-
textInputAction.
final
- theme → M3ETextFieldTheme?
-
Per-field theme. Default:
M3EThemeData.textFieldTheme.final - trailing → Widget?
-
Trailing icon or 24dp image.
final
- variant → M3ETextFieldVariant
-
variant.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< M3ETextField> -
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
-
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