TextField简介
文本输入框(和Android的EditText差不多)
TextField属性概要
TextField({
Key key,
this.controller,// 编辑框的控制器,设置/获取编辑框的内容、选择编辑内容、监听编辑文本改变事件
this.focusNode,// 控制TextField是否占有当期键盘的输入焦点
this.decoration = const InputDecoration(),// 控制TextField外观显示,提示文本、背景、边框等
TextInputType keyboardType,// 设置输入框默认的键盘输入类型
this.textInputAction,// 设置键盘动作按键图标,枚举类型
this.textCapitalization = TextCapitalization.none,// 文本大写
this.style, // 正在编辑的文本样式
this.strutStyle,
this.textAlign = TextAlign.start,// 输入框内编辑文本在水平方向的对齐方式
this.textAlignVertical,
this.textDirection,// 文字浏览方向(从左往右,从右往左)
this.readOnly = false,
ToolbarOptions toolbarOptions,
this.showCursor,
this.autofocus = false,// 是否自动获取焦点
this.obscureText = false, // 是否影藏正在编辑的文本,如输入密码等场景、文本内容会用.代替
this.autocorrect = true,// 自动更正
this.maxLines = 1,// 输入框文本最大行数(默认为1,null为无限)
this.minLines,// 输入框最小行数
this.expands = false,//
this.maxLength,// 最大文本输入长度(会显示文本计数)
this.maxLengthEnforced = true,// 是否允许超出最大文本长度
this.onChanged,// 输入内容改变回调函数
this.onEditingComplete,// 输入完成时触发,如按了键盘的完成键(无接受参数)
this.onSubmitted,// 输入完成时触发,如按了键盘的完成键(接收参数ValueChanged<String>)
this.inputFormatters,// 用于指定输入格式,用户输入内容改变时会根据指定格式来校验
this.enabled,// 设置是否禁用输入功能
this.cursorWidth = 2.0,// 设置输入框光标宽度
this.cursorRadius,// 设置输入框光标圆角
this.cursorColor,// 设置输入框光标颜色
this.keyboardAppearance,// 设置键盘外观
this.scrollPadding = const EdgeInsets.all(20.0),// 滚动Padding
this.dragStartBehavior = DragStartBehavior.start,
this.enableInteractiveSelection = true,// 启用交互选项
this.onTap,// 点击事件
this.buildCounter,
this.scrollController,
this.scrollPhysics,
})
参看文献:之后再整理
https://medium.com/flutterpub/flutter-keyboard-actions-and-next-focus-field-3260dc4c694