censorEmail method

String censorEmail({
  1. int begin = 4,
  2. int end = 4,
  3. int asterisks = 4,
})

Implementation

String censorEmail({int begin = 4, int end = 4, int asterisks = 4}) {
  final int count = length;
  final StringBuffer censor = StringBuffer();
  asterisks.forEach((_) => censor.write("*"));

  if (count >= begin + end) {
    return "${substring(0, begin)}$censor${substring(count - end, count)}";
  }
  return this;
}