Reputation: 3009
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
Upvotes: -1
Views: 172
Reputation: 4696
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, '');
}
Upvotes: 1