-1

I have a Flutter text widget in my login screen that users enters their username in plain text. How can I prevent then from entering HTML characters in the field.

For example, they enter <p>myname</p>

Thanks

1 Answer 1

1

You can try using RegEx for that like so

 String stripHtml(String s) {
    if (s.isEmpty) {
      return s;
    }
    var regex = RegExp(r'<[^>]*>');
    return s.replaceAll(regex, '');
  }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.