问题描述
如何通过在用户输入完毕后自动删除该空格来限制用户在文本字段中使用空格?
例如,如果用户键入King of Light
,则他/她离开文本字段后将以KingofLight
的身份应用。
TextFormField(
initialValue: nickname != null
? nickname
: current_user.nickname,decoration: InputDecoration(
border: new OutlineInputBorder(
borderSide: new BorderSide(color: Colors.grey),borderRadius: BorderRadius.circular(6),),focusedBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey,width: 1.0),enabledBorder: OutlineInputBorder(
borderSide:
BorderSide(color: Colors.grey,hintText: 'Empty',hintStyle: TextStyle(
color: Colors.grey[400],fontSize: 20,//fontWeight: FontWeight.bold,style: TextStyle(
fontSize: 20,// fontWeight: FontWeight.bold,validator: (val) => val.length < 2
? 'Enter a nickname 2+char long'
: null,onChanged: (val) {
val = val.replaceAll(' ','');
setState(() => nickname = val);
},
请帮助我!谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)