且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

仅允许小写且无空格输入文本字段颤动

更新时间:1970-01-01 07:57:36

Ffltter的TextFieldTextFormField具有名为inputFormatters的属性,该属性采用TextInputFormatter的列表。

适用于您的案例的TextInputFormatters示例。

FilteringTextInputFormatter.allow(RegExp("[a-z]"))

TextField(
 inputFormatters: <TextInputFormatter>[
  FilteringTextInputFormatter.allow(RegExp("[a-z]")),
 ],
)

您可以在这里看到TextInputFormatters接口文档:Reference


(颤动1.20之前):

WhitelistingTextInputFormatter(RegExp("[a-z]")),

TextField(
 inputFormatters: <TextInputFormatter>[
  WhitelistingTextInputFormatter(RegExp("[a-z]")),
 ],
)

不清楚可以参考:Reference 2Reference 3

另请查看此SOF问题:Reference 4