MTextField class
Constructors
-
MTextField({Key? key, TextEditingController? controller, FocusNode? focusNode, UndoHistoryController? undoController, InputDecoration? decoration, 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, MaterialStatesController? statesController, String obscuringCharacter = '•', bool obscureText = false, bool autocorrect = true, SmartDashesType? smartDashesType, SmartQuotesType? smartQuotesType, bool enableSuggestions = true, int? maxLines = 1, int? minLines, bool expands = false, int? maxLength, MaxLengthEnforcement? maxLengthEnforcement, ValueChanged<String>? onChanged, VoidCallback? onEditingComplete, ValueChanged<String>? onSubmitted, AppPrivateCommandCallback? onAppPrivateCommand, List<TextInputFormatter>? inputFormatters, bool? enabled, double cursorWidth = 2.0, double? cursorHeight, Radius? cursorRadius, bool? cursorOpacityAnimates, Color? cursorColor, Color? cursorErrorColor, BoxHeightStyle selectionHeightStyle = ui.BoxHeightStyle.tight, BoxWidthStyle selectionWidthStyle = ui.BoxWidthStyle.tight, Brightness? keyboardAppearance, EdgeInsets scrollPadding = const EdgeInsets.all(20.0), DragStartBehavior dragStartBehavior = DragStartBehavior.start, bool? enableInteractiveSelection, TextSelectionControls? selectionControls, GestureTapCallback? onTap, bool onTapAlwaysCalled = false, TapRegionCallback? onTapOutside, MouseCursor? mouseCursor, InputCounterWidgetBuilder? buildCounter, ScrollController? scrollController, ScrollPhysics? scrollPhysics, Iterable<String>? autofillHints = const <String>[], ContentInsertionConfiguration? contentInsertionConfiguration, Clip clipBehavior = Clip.hardEdge, String? restorationId, bool scribbleEnabled = true, bool enableIMEPersonalizedLearning = true, bool canRequestFocus = true, SpellCheckConfiguration? spellCheckConfiguration, TextMagnifierConfiguration? magnifierConfiguration, double? fontSize, FontWeight? fontWeight, Color? color, bool isBold = false, bool forceStrutHeight = false, bool? filled, InputBorder? errorBorder, InputBorder? focusedBorder, InputBorder? focusedErrorBorder, InputBorder? disabledBorder, InputBorder? enabledBorder, InputBorder? border, String? text, Color? fillColor, double? width, double? height, BoxConstraints? constraints, BorderRadius? borderRadius, double? radius, BorderSide? side, MTextFieldBorderStyle borderStyle = MTextFieldBorderStyle.underline, double? gapPadding, Widget? icon, Color? iconColor, Widget? label, String? labelText, TextStyle? labelStyle, TextStyle? floatingLabelStyle, String? helperText, TextStyle? helperStyle, int? helperMaxLines, String? hintText, Color? hintColor, TextStyle? hintStyle, TextDirection? hintTextDirection, int? hintMaxLines, Duration? hintFadeDuration, Widget? error, String? errorText, TextStyle? errorStyle, int? errorMaxLines, FloatingLabelBehavior? floatingLabelBehavior, FloatingLabelAlignment? floatingLabelAlignment, bool? isCollapsed, bool? isDense, EdgeInsetsGeometry? contentPadding, Widget? prefixIcon, BoxConstraints? prefixIconConstraints, Widget? prefix, String? prefixText, TextStyle? prefixStyle, Color? prefixIconColor, Widget? suffixIcon, Widget? suffix, String? suffixText, TextStyle? suffixStyle, Color? suffixIconColor, BoxConstraints? suffixIconConstraints, EdgeInsetsGeometry? suffixPadding, EdgeInsetsGeometry? suffixIconPadding, Widget? counter, String? counterText, TextStyle? counterStyle, bool? alignLabelWithHint, Color? focusColor, Color? hoverColor, String? semanticCounterText})
-
Creates a Material Design TextField.
const
Properties
-
alignLabelWithHint
→ bool?
-
如果 labelText 或者 helperText 存在,则将此标签与它们对齐
final
-
autocorrect
→ bool
-
final
-
autofillHints
→ Iterable<String>?
-
final
-
autofocus
→ bool
-
final
-
border
→ InputBorder?
-
输入框的边框, 默认情况下为 InputBorder.none.
如果设置了borderRadius 或 radius 或 side 或 gapPadding, 则根据 borderStyle 重新计算边框
final
-
borderRadius
→ BorderRadius?
-
圆角
final
-
borderStyle
→ MTextFieldBorderStyle
-
边框样式, 默认 MTextFieldBorderStyle.underline
final
-
buildCounter
→ InputCounterWidgetBuilder?
-
final
-
canRequestFocus
→ bool
-
final
-
clipBehavior
→ Clip
-
final
-
color
→ Color?
-
字体颜色
final
-
constraints
→ BoxConstraints?
-
输入框的大小约束
final
-
contentInsertionConfiguration
→ ContentInsertionConfiguration?
-
final
-
contentPadding
→ EdgeInsetsGeometry?
-
内容的内边距
默认情况下,contentPadding 反映 isDense 和 border 的类型。
如果 isCollapsed 为true,那么 contentPadding 就是 EdgeInsets.zero。
如果 border 的
isOutline 属性为假,且 filled 为真,
则当 isDense 为真时,contentPadding 为 EdgeInsets.fromLTRB(12, 8, 12, 8);
当 isDense 为假时,contentPadding 为 EdgeInsets.fromLTRB(12, 12, 12, 12)。
如果 border 的 isOutline 属性为 false,且 filled 为 false,
则当 isDense 为真时,contentPadding 为 EdgeInsets.fromLTRB(0, 8, 0, 8);
当 isDense 为假时,contentPadding 为 EdgeInsets.fromLTRB(0, 12, 0, 12)。
如果 border 的 isOutline 属性为 true,
则当 isDense 为 true 时,contentPadding 为 EdgeInsets.fromLTRB(12, 20, 12, 12);
当 isDense 为 false 时,contentPadding 为 EdgeInsets.fromLTRB(12, 24, 12, 16)。
如果设置了 suffix 相关属性,则此属性的 EdgeInsetsGeometry.right 将被忽略
final
-
final
-
controller
→ TextEditingController?
-
final
-
counter
→ Widget?
-
计数器
final
-
counterStyle
→ TextStyle?
-
计数器的样式
final
-
counterText
→ String?
-
计数器的文本
final
-
cursorColor
→ Color?
-
final
-
cursorErrorColor
→ Color?
-
final
-
cursorHeight
→ double?
-
final
-
cursorOpacityAnimates
→ bool?
-
final
-
cursorRadius
→ Radius?
-
final
-
cursorWidth
→ double
-
final
-
decoration
→ InputDecoration?
-
final
-
disabledBorder
→ InputBorder?
-
禁用状态下的边框
final
-
dragStartBehavior
→ DragStartBehavior
-
final
-
enabled
→ bool?
-
是否启用输入框
final
-
enabledBorder
→ InputBorder?
-
启用状态下的边框
final
-
enableIMEPersonalizedLearning
→ bool
-
final
-
enableInteractiveSelection
→ bool
-
final
-
enableSuggestions
→ bool
-
final
-
error
→ Widget?
-
错误提示
final
-
errorBorder
→ InputBorder?
-
错误状态下的边框
final
-
errorMaxLines
→ int?
-
错误提示的最大行数
final
-
errorStyle
→ TextStyle?
-
错误提示的样式
final
-
errorText
→ String?
-
错误提示的文本
final
-
expands
→ bool
-
final
-
fillColor
→ Color?
-
输入框填充的颜色
final
-
filled
→ bool?
-
是否填充输入框
如果为 "true",装饰的容器将被填充为 fillColor。
默认为 "false", 当 fillColor 不为 null 时默认为 "true".
final
-
floatingLabelAlignment
→ FloatingLabelAlignment?
-
标签的对齐方式
final
-
floatingLabelBehavior
→ FloatingLabelBehavior?
-
标签的行为
final
-
floatingLabelStyle
→ TextStyle?
-
标签的样式
final
-
focusColor
→ Color?
-
输入框获取焦点时的颜色
final
-
focusedBorder
→ InputBorder?
-
获取焦点时的边框
final
-
focusedErrorBorder
→ InputBorder?
-
获取焦点时的错误边框
final
-
focusNode
→ FocusNode?
-
final
-
fontSize
→ double?
-
字体大小
final
-
fontWeight
→ FontWeight?
-
字体粗细
final
-
forceStrutHeight
→ bool
-
是否强制设置支柱高度。默认值为 false。
final
-
gapPadding
→ double?
-
边框两侧的水平填充, 默认值为 4.0
InputDecoration.labelText 宽度间隙.
final
-
hashCode
→ int
-
The hash code for this object.
no setterinherited
-
height
→ double?
-
限定文本高度, 会限定 MTextField 高度为 height,
如果想设置初始高度, 在 maxLines > 1, 并且希望 MTextField 自适应高度的情况下,
推荐设置 isDense 为 true, 配合 contentPadding 来控制初始高度
final
-
helperMaxLines
→ int?
-
帮助提示的最大行数
final
-
helperStyle
→ TextStyle?
-
帮助提示的样式
final
-
helperText
→ String?
-
帮助提示的文本
final
-
hintColor
→ Color?
-
提示颜色
final
-
hintFadeDuration
→ Duration?
-
提示文字淡出动画的持续时间
final
-
hintMaxLines
→ int?
-
提示文字的最大行数
final
-
hintStyle
→ TextStyle?
-
提示文字的样式
final
-
hintText
→ String?
-
提示文字的文本
final
-
hintTextDirection
→ TextDirection?
-
提示文字的方向
final
-
hoverColor
→ Color?
-
鼠标悬浮时的颜色
final
-
icon
→ Widget?
-
前缀图标
final
-
iconColor
→ Color?
-
前缀图标的颜色
final
-
inputFormatters
→ List<TextInputFormatter>?
-
final
-
isBold
→ bool
-
是否为粗体
final
-
isCollapsed
→ bool?
-
是否折叠
final
-
isDense
→ bool?
-
是否紧凑
final
-
key
→ Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
keyboardAppearance
→ Brightness?
-
final
-
keyboardType
→ TextInputType
-
final
-
label
→ Widget?
-
标签
final
-
labelStyle
→ TextStyle?
-
标签的样式
final
-
labelText
→ String?
-
标签的文本
final
-
magnifierConfiguration
→ TextMagnifierConfiguration?
-
final
-
maxLength
→ int?
-
final
-
maxLengthEnforcement
→ MaxLengthEnforcement?
-
final
-
maxLines
→ int?
-
final
-
minLines
→ int?
-
final
-
mouseCursor
→ MouseCursor?
-
final
-
obscureText
→ bool
-
final
-
obscuringCharacter
→ String
-
final
-
onAppPrivateCommand
→ AppPrivateCommandCallback?
-
final
-
onChanged
→ ValueChanged<String>?
-
final
-
onEditingComplete
→ VoidCallback?
-
final
-
onSubmitted
→ ValueChanged<String>?
-
final
-
onTap
→ GestureTapCallback?
-
final
-
onTapAlwaysCalled
→ bool
-
final
-
onTapOutside
→ TapRegionCallback?
-
final
-
prefix
→ Widget?
-
前缀
final
-
prefixIcon
→ Widget?
-
前缀图标
final
-
prefixIconColor
→ Color?
-
前缀图标的颜色
final
-
prefixIconConstraints
→ BoxConstraints?
-
前缀图标的约束
final
-
prefixStyle
→ TextStyle?
-
前缀的样式
final
-
prefixText
→ String?
-
前缀的文本
final
-
radius
→ double?
-
圆角半径
final
-
readOnly
→ bool
-
final
-
restorationId
→ String?
-
final
-
runtimeType
→ Type
-
A representation of the runtime type of the object.
no setterinherited
-
scribbleEnabled
→ bool
-
final
-
scrollController
→ ScrollController?
-
final
-
scrollPadding
→ EdgeInsets
-
final
-
scrollPhysics
→ ScrollPhysics?
-
final
-
selectionControls
→ TextSelectionControls?
-
final
-
selectionEnabled
→ bool
-
no setter
-
selectionHeightStyle
→ BoxHeightStyle
-
final
-
selectionWidthStyle
→ BoxWidthStyle
-
final
-
semanticCounterText
→ String?
-
统计信息的文本,用于读屏软件
final
-
showCursor
→ bool?
-
final
-
side
→ BorderSide?
-
边框颜色粗细等样式
final
-
smartDashesType
→ SmartDashesType
-
final
-
smartQuotesType
→ SmartQuotesType
-
final
-
spellCheckConfiguration
→ SpellCheckConfiguration?
-
final
-
statesController
→ MaterialStatesController?
-
final
-
strutStyle
→ StrutStyle?
-
final
-
style
→ TextStyle?
-
final
-
suffix
→ Widget?
-
后缀
final
-
suffixIcon
→ Widget?
-
后缀图标
final
-
suffixIconColor
→ Color?
-
后缀图标的颜色
final
-
suffixIconConstraints
→ BoxConstraints?
-
后缀图标的约束, 比如限制宽高
final
-
suffixIconPadding
→ EdgeInsetsGeometry?
-
后缀图标的边距
final
-
suffixPadding
→ EdgeInsetsGeometry?
-
后缀的边距
final
-
suffixStyle
→ TextStyle?
-
后缀的样式
final
-
suffixText
→ String?
-
后缀的文本, 如果和 suffixIcon 一起使用,会显示在图标的前面
final
-
text
→ String?
-
默认文本
final
-
textAlign
→ TextAlign
-
final
-
textAlignVertical
→ TextAlignVertical?
-
final
-
textCapitalization
→ TextCapitalization
-
final
-
textDirection
→ TextDirection?
-
final
-
textInputAction
→ TextInputAction?
-
final
-
undoController
→ UndoHistoryController?
-
final
-
width
→ double?
-
文本宽度
final