isValidName method

bool isValidName()

Checks if the string is a valid name. A valid name shouldn't contain any symbols or special characters.

Example:

print('John'.isValidName()); // true
print('John#Doe'.isValidName());  // false

Implementation

bool isValidName() {
  final nameRegExp = RegExp(r'[!@#<>?":_`~;[\]\\|=+)(*&^%\s]');
  return !nameRegExp.hasMatch(this);
}