maskEmail property

String get maskEmail

Masks the email address for privacy. Example: "johndoe@gmail.com" -> "jo****@gmail.com"

Implementation

String get maskEmail {
  if (this == null || !this!.isValidEmail) return this ?? '';
  final index = this!.indexOf('@');
  if (index <= 2) return '${this![0]}****${this!.substring(index)}';
  return '${this!.substring(0, 2)}****${this!.substring(index)}';
}