如何限制 flutter Textfield 或 TextFormField 只接受英文??不允许其他语言进入。
最佳答案
试试这个
TextField(
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp("^[\u0000-\u007F]+\$"))
])
或者如果你只想要英文字符,你可以试试这个。
TextField(
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp("[a-zA-Z]"))
])
关于flutter - 如何限制 flutter Textfield 或 TextFormField 只接受英语?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70830888/