TextFormField(
autofocus: true,
textInputAction: TextInputAction.next,
decoration: InputDecoration(
filled: true,
hintText: 'Your email address',
labelText: 'Email',
),
onChanged: (value) {
formData.email = value;
},
)
TextFormField 主要有以下属性:
autofocus 自动聚集
textInputAction 键盘操作按钮的类型,接收一个TextInputAction 类型的值。一般用InputDecoration修饰
decoration 修饰,主要通过文本,边框,图标,样式等进行修饰
onChanged 修改
maxLines: 5, 最大行数,比如为5
TextFormField(
decoration: InputDecoration(
hintText: 'Password',
),
obscureText: true,//密码可以加上这一项
),
---示例来自于官方的示例,里面的日期写的很好
Flutter文本输入字段详解与示例
这篇博客详细介绍了Flutter中的TextFormField组件,包括autofocus自动聚焦、textInputAction键盘操作、decoration输入框装饰以及onChanged事件处理。示例中展示了如何设置密码输入、自定义提示文本和标签,对于前端开发人员理解Flutter的UI构建具有指导意义。
2280

被折叠的 条评论
为什么被折叠?



