Flutter Web Regex-How to handle throw exception when turning on caps lock button

126 views Asked by At

I am tying to use regex for validation email and password in flutter web project, here is the part of the code

TextField(
              onChanged: (text) {
                  bool passValid =
                      RegExp(r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9]).{6,}$')
                          .hasMatch(text);
                  setState(() {
                    repasswordVal = passValid;
                  });
                  print(repasswordVal);
                },
                controller: _repassword,
                decoration: new InputDecoration(
                  suffixIcon: GestureDetector(
                    onTap: () {
                      setState(() {
                        _isHideRePassword = !_isHideRePassword;
                      });
                    },
                  ),
              labelText: "Re-enter Password",
              fillColor: Colors.white,
              border: new OutlineInputBorder(
                borderSide: new BorderSide(color: Colors.black),
              ),
            )),

but when I turning on the capslock keyboard, I always get this exception enter image description here actually I can ignore this exception because the project can still run correctly, but is there any solution to prevent this exception?

0

There are 0 answers