isStrongPassword method

bool isStrongPassword()

A strong password must:

  • Be at least 8 characters long
  • Contain at least one uppercase letter
  • Contain at least one lowercase letter
  • Contain at least one digit
  • Contain at least one special character

Implementation

bool isStrongPassword() {
  final passwordRegex = RegExp(
      r'^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[@$!%*?&#])[A-Za-z\d@$!%*?&#]{8,}$');
  return passwordRegex.hasMatch(this);
}