const TextField({ Key key, this.controller, this.focusNode, this.decoration = const InputDecoration(), 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.enableSuggestions = true, this.maxLines = 1, this.minLines, this.expands = false, this.maxLength, this.maxLengthEnforced = true, this.onChanged, // 内容发生改变方法回调 this.onEditingComplete, // 完成编辑方法回调,实现了这个方法,键盘不再会自动收起 this.onSubmitted, // 提交方法回调 this.inputFormatters, this.enabled, this.cursorWidth = 2.0, // 光标宽度 this.cursorRadius, // 光标圆角 this.cursorColor, // 光标颜色 this.keyboardAppearance, this.scrollPadding = const EdgeInsets.all(20.0), this.dragStartBehavior = DragStartBehavior.start, this.enableInteractiveSelection = true, this.onTap, // 点击方法回调(开始编辑) this.buildCounter, // (BuildContext context, {int currentLength, int maxLength, bool isFocused, }) {} counter 回调 this.scrollController, // 滚动 this.scrollPhysics, })
Flutter TextField 的详细属性说明
24 min read