TextField
顾名思义文本输入框,类似于Ios中的UITextField和Android中的EditText和Web中的TextInput。主要是为用户提供输入文本提供方便。
const TextField({
Key key, this.controller,
//控制器,控制TextField文字
this.focusNode,
this.decoration:
const InputDecoration(),
//输入器装饰
TextInputType keyboardType: TextInputType.text,
//输入的类型
this.style, this.textAlign: TextAlign.start,
this.autofocus: false,
this.obscureText: false,
//是否隐藏输入
this.autocorrect: true,
this.maxLines: 1,
this.maxLength,
this.maxLengthEnforced: true,
this.onChanged, //文字改变触发
this.onSubmitted, //文字提交触发(键盘按键)
this.onEditingComplete, //当用户提交可编辑内容时调用
this.inputFormatters,
this.enabled,
this.cursorWidth = 2.0,
this.cursorRadius,
this.cursorColor,
this.keyboardAppearance,
})
以下是一个简单的demo
TextField.png
new TextField(
//controller: phoneController,
keyboardType: TextInputType.text,
decoration: InputDecoration(
contentPadding: EdgeInsets.all(10.0),
icon: Icon(Icons.card_membership),
labelText: '请输入你的用户名',
helperText: '请输入注册的用户名',
),
autofocus: false,
),
网友评论