Prevent whitespaces in TextField widget

Hi everyone ๐Ÿ‘‹

I want to prevent the User to type any space into a Text Field for email. In Flutter, I found we could do something like this:

FilteringTextInputFormatter.deny( RegExp(r'\s')), );

But the UI builder does not seems to provide a way to DENY characters. The only option available is to provide a Custom Filter RexExp value for ALLOWED chars.

It seems like it could be a smoother ride to deny a single char than listing out all the approved characters, as we might accidentally wipe out something important or overlook that one crucial character.

Thanks!

โ€“โ€“โ€“โ€“โ€“โ€“โ€“โ€“

UPDATE: Removed my initial workaround, after multiple tests, I found that the expression was incomplete.

2
4 replies