TextField简介

文本输入框(和Android的EditText差不多)

TextField属性概要

  1. TextField({
  2. Key key,
  3. this.controller,// 编辑框的控制器,设置/获取编辑框的内容、选择编辑内容、监听编辑文本改变事件
  4. this.focusNode,// 控制TextField是否占有当期键盘的输入焦点
  5. this.decoration = const InputDecoration(),// 控制TextField外观显示,提示文本、背景、边框等
  6. TextInputType keyboardType,// 设置输入框默认的键盘输入类型
  7. this.textInputAction,// 设置键盘动作按键图标,枚举类型
  8. this.textCapitalization = TextCapitalization.none,// 文本大写
  9. this.style, // 正在编辑的文本样式
  10. this.strutStyle,
  11. this.textAlign = TextAlign.start,// 输入框内编辑文本在水平方向的对齐方式
  12. this.textAlignVertical,
  13. this.textDirection,// 文字浏览方向(从左往右,从右往左)
  14. this.readOnly = false,
  15. ToolbarOptions toolbarOptions,
  16. this.showCursor,
  17. this.autofocus = false,// 是否自动获取焦点
  18. this.obscureText = false, // 是否影藏正在编辑的文本,如输入密码等场景、文本内容会用.代替
  19. this.autocorrect = true,// 自动更正
  20. this.maxLines = 1,// 输入框文本最大行数(默认为1,null为无限)
  21. this.minLines,// 输入框最小行数
  22. this.expands = false,//
  23. this.maxLength,// 最大文本输入长度(会显示文本计数)
  24. this.maxLengthEnforced = true,// 是否允许超出最大文本长度
  25. this.onChanged,// 输入内容改变回调函数
  26. this.onEditingComplete,// 输入完成时触发,如按了键盘的完成键(无接受参数)
  27. this.onSubmitted,// 输入完成时触发,如按了键盘的完成键(接收参数ValueChanged<String>)
  28. this.inputFormatters,// 用于指定输入格式,用户输入内容改变时会根据指定格式来校验
  29. this.enabled,// 设置是否禁用输入功能
  30. this.cursorWidth = 2.0,// 设置输入框光标宽度
  31. this.cursorRadius,// 设置输入框光标圆角
  32. this.cursorColor,// 设置输入框光标颜色
  33. this.keyboardAppearance,// 设置键盘外观
  34. this.scrollPadding = const EdgeInsets.all(20.0),// 滚动Padding
  35. this.dragStartBehavior = DragStartBehavior.start,
  36. this.enableInteractiveSelection = true,// 启用交互选项
  37. this.onTap,// 点击事件
  38. this.buildCounter,
  39. this.scrollController,
  40. this.scrollPhysics,
  41. })

参看文献:之后再整理
https://medium.com/flutterpub/flutter-keyboard-actions-and-next-focus-field-3260dc4c694