Restrict Special Character Input Flutter

In your TextInputField(), use a FilteringTextInputFormatter like this:

TextField(
 inputFormatters: <TextInputFormatter>[
      FilteringTextInputFormatter.allow(RegExp("[0-9a-zA-Z]")),
  ], // Only numbers can be entered
),

Each character typed will be allowed only if it matches the RegExp. To include a space, use the regular expression "[0-9a-zA-Z ]" instead. Period means “any character” in regular expressions unless you escape them, like "[0-9\.a-zA-Z]".

.deny can be used in place of .allow to proved a blacklist instead of a whitelist.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)