username static method
Validate string as a username.
The str
parameter should be a string representing a username.
Returns true
if the str
is valid, false
otherwise.
Implementation
static bool username(String str) {
String pattern = r'^[a-z0-9_-]{3,16}$';
RegExp regExp = RegExp(pattern);
return regExp.hasMatch(str);
}