MTextField class
A customizable text field widget with optional label and various input controls.
This widget provides a complete text input solution with support for features like obscuring text, read-only mode, custom colors, and more.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- MTextField
Constructors
- MTextField.new({Key? key, String? label, Color? labelColor, Color? borderColor, Color? fillColor, Color? fontColor, String? hintText, dynamic initialValue, dynamic updateValue(String value)?, dynamic obscureTextFunction()?, dynamic submitAction(String value)?, bool? descriptionLowercased, bool? obscureText, bool? readOnly, bool? textCapitalization, double? height, Color? mainColor, TextInputAction? textInputAction, TextInputType? keyboardType, TextEditingController? textEditingController, TextAlignVertical? textAlignVertical, int? maxLines, TextAlign textAlign = TextAlign.start, FormFieldValidator? validator, double? fontSize, InputBorder? border})
-
Creates a customizable text field.
const
Properties
- border → InputBorder?
-
final
- borderColor → Color?
-
final
- descriptionLowercased → bool?
-
When true, the label is displayed in lowercase. Otherwise, it's in uppercase.
Defaults to false if not specified.
final
- fillColor → Color?
-
final
- fontColor → Color?
-
final
- fontSize → double?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double?
-
Height of the text field.
Defaults to 55 if not specified.
final
- hintText → String?
-
Placeholder text displayed when the text field is empty.
final
- initialValue → dynamic
-
Initial value of the text field.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- keyboardType → TextInputType?
-
The type of keyboard to display (e.g., text, number, email).
final
- label → String?
-
Optional label displayed next to the text field.
By default, displayed in uppercase unless descriptionLowercased is true.
final
- labelColor → Color?
-
final
- mainColor → Color?
-
The primary color for the text field focus and cursor.
Defaults to blue if not specified.
final
- maxLines → int?
-
Maximum number of lines for a multiline TextField.
If set, the keyboard will be automatically set to
TextInputType.multiline, and will be removed any
obsfuscation implementation, since Flutter doesn't
allow maxLines and obscureText to coexist. Moreover,
if height is not specified, it will be automatically
set based on the number of maxLines.
final
- obscureText → bool?
-
When true, the text is obscured (for password input).
Defaults to false if not specified.
final
- obscureTextFunction → dynamic Function()?
-
Callback function to toggle the visibility of the text (for password fields).
Used when obscureText is provided.
final
- readOnly → bool?
-
When true, the text field cannot be edited.
Defaults to false if not specified.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- submitAction → dynamic Function(String value)?
-
Callback function triggered when the user submits the text field.
final
- textAlign → TextAlign
-
final
- textAlignVertical → TextAlignVertical?
-
Vertical alignment of text within the text field.
Defaults to TextAlignVertical.top if not specified.
final
- textCapitalization → bool?
-
When true, text is automatically capitalized.
Defaults to false if not specified.
final
- textEditingController → TextEditingController?
-
Optional controller for the text field.
If not provided, an internal controller is created.
final
- textInputAction → TextInputAction?
-
The keyboard action button type (e.g., next, done, send).
final
- updateValue → dynamic Function(String value)?
-
Callback function triggered when the text field value changes.
final
- validator → FormFieldValidator?
-
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< MTextField> -
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