MaterialTextField class

This is a magic widget, you can use for text input field with custom styling. You can define theming of text field in app level theme file, or You can create different fields with different styling

Inheritance

Constructors

MaterialTextField({Key? key, TextInputType? keyboardType, TextEditingController? controller, FormFieldValidator<String>? validator, TextInputAction? textInputAction, Widget? suffixIcon, Widget? prefixIcon, String? hint, bool obscureText = false, bool enabled = true, ValueChanged<String>? onChanged, TextStyle? style, Widget? icon, Color? iconColor, TextStyle? errorStyle, int? errorMaxLines, String? errorText, FloatingLabelAlignment? floatingLabelAlignment, FloatingLabelBehavior? floatingLabelBehavior, int? helperMaxLines, TextStyle? helperStyle, String? helperText, int? hintMaxLines, TextDirection? hintTextDirection, Color? suffixIconColor, Color? prefixIconColor, TextStyle? prefixStyle, String? prefixText, TextStyle? suffixStyle, String? suffixText, String? labelText, InputDecorationTheme? theme, int? maxLength})
const

Properties

controller TextEditingController?
A controller for an editable text field.
final
enabled bool
Enable/disable value entering in the input field Default value of this is true, which makes it enable.
final
errorMaxLines int?
The maximum number of lines the errorText can occupy.
final
errorStyle TextStyle?
The style to use for the errorText.
final
errorText String?
Text that appears below the InputDecorator.child and the border.
final
floatingLabelAlignment FloatingLabelAlignment?
Defines where the floating label should be displayed.
final
floatingLabelBehavior FloatingLabelBehavior?
Defines how the floating label should behave. When FloatingLabelBehavior.auto the label will float to the top only when the field is focused or has some text content, otherwise it will appear in the field in place of the content. When FloatingLabelBehavior.always the label will always float at the top of the field above the content. When FloatingLabelBehavior.never the label will always appear in an empty field in place of the content.
final
hashCode int
The hash code for this object.
no setterinherited
helperMaxLines int?
The maximum number of lines the helperText can occupy.
final
helperStyle TextStyle?
The style to use for the helperText
final
helperText String?
Text that provides context about the InputDecorator.child's value, such as how the value will be used.
final
hint String?
Hint text, shows within the container of field
final
hintMaxLines int?
The maximum number of lines the hint can occupy.
final
hintTextDirection TextDirection?
The direction to use for the hintText
final
icon Widget?
An icon to show before the input field and outside of the decoration's
final
iconColor Color?
The color of the icon
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
keyboardType TextInputType?
The type of information for which to optimize the text input control
final
labelText String?
Label text for outlined text field
final
maxLength int?
The maximum number of characters (Unicode grapheme clusters) to allow in the text field.
final
obscureText bool
Pass true to hide the data entered in the input field The default of this is false, which makes it visible to us Often used for password field
final
onChanged ValueChanged<String>?
Signature for callbacks that report that an underlying value has changed.
final
prefixIcon Widget?
An icon that appears before the editable part of the text field
final
prefixIconColor Color?
Optional color of the prefixIcon
final
prefixStyle TextStyle?
The style to use for the prefixText.
final
prefixText String?
Optional text prefix to place on the line before the input.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
style TextStyle?
Text styling of input field
final
suffixIcon Widget?
An icon that appears after the editable part of the text field
final
suffixIconColor Color?
Optional color of the suffixIcon
final
suffixStyle TextStyle?
The style to use for the suffixStyle.
final
suffixText String?
Optional text suffix to place on the line before the input.
final
textInputAction TextInputAction?
An action the user has requested the text input control to perform
final
theme InputDecorationTheme?
You can also pass custom theming to this class which is differ from app level theming.
final
validator FormFieldValidator<String>?
Signature for validating a form field. Returns an error string to display if the input is invalid, or null
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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}) 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