通过TextField组件 输入框inputFormatters属性限制
FilteringTextInputFormatter.allow() (白名单校验),表示只允许输入符合规则的字符 ;
FilteringTextInputFormatter.deny()(黑名单校验),除了规定的字符,其他都可以输入;
LengthLimitingTextInputFormatter (),(长度限制)
常用正则匹配
/// 禁止输入空格
static const String regexNotNull = "[\\s]";
/// 第一个输入字符不能为空格
static const String regexFirstNotNull = r'^(\S){
1}';
///仅支持数字
static const String regexOnlyNumber = "[0-9]";
///仅支持字母和数字
static const String regexOnlyNumberText = "[a-zA-Z]|[0-9]";
- 邮箱: (邮箱键盘,禁止输入空格,限制30位)
TextField(
key: emailKey,
keyboardType: TextInputType.emailAddress,
controller: logic.emailContr