//TextField和TextFormField的区别在于TextFormField可以使用validator进行判断
TextFormField(
onChanged: (v){
print("这个是 onChanged 时刻在监听,输出的信息是:${v}");
},
//居中显示
//textAlign: TextAlign.center,
**//autofocus自动获取焦点**
autofocus: true,
//输入的类型
keyboardType: TextInputType.number,
//阻止按下回车键丢失焦点
//textInputAction: TextInputAction.next,
//controller: 定义的变量,(将输入框中的值加入变量)
decoration: InputDecoration(
labelText: "用户名或邮箱",
hintText: "用户名或邮箱",
//圆角矩形边框
//border: OutlineInputBorder(),
icon: Icon(Icons.person)),
//是否隐藏文本
obscureText: false,
//光标样式
// cursorColor: Colors.yellow,
// cursorWidth: 2,
// cursorRadius: Radius.circular(5),
// 校验用户名
validator: (v) {
return v.trim().length > 0 ? null : "用户名不能为空";
}),
flutter 输入框 TextFiled详解
猜你喜欢
转载自blog.csdn.net/txaz6/article/details/109000048
今日推荐
周排行