isValidUsername property Null safety

bool isValidUsername

Validates a user name.

A valid username contains a minimum of 3 characters, Contain only: Uppercase letters (A-Z), Lowercase letters (a-z), Numeric digits (0-9), Contain no other types of characters, symbols, or spaces.

Implementation

bool get isValidUsername {
  // Regex taken from:
  // https://stackoverflow.com/questions/49757486/how-to-use-regex-in-dart
  final nameRegExp = RegExp(r'^[a-zA-Z0-9]+$');
  return nameRegExp.hasMatch(this) && isOfMinimumLength(3);
}