将WhitelistingTextInputFormatter(RegExp("[0-9]"))升级FilteringTextInputFormatter.allow(RegExp("[0-9]")),
一下为新方法
1.只允许输入数
TextField(
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp("[0-9.]")),
],
),
2.only allow a to Z
TextField(
FilteringTextInputFormatter.allow(RegExp('[a-zA-Z]')
),
3.禁止abF!.
inputFormatters: [
FilteringTextInputFormatter.deny(RegExp('[abF!.]')
),
],
4.允许输入大小写字母,但是禁止abF!.
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp('[a-zA-Z]')),
FilteringTextInputFormatter.deny(RegExp('[abFeG]')),
],
网友评论