secretMiddleString method

String secretMiddleString()

Implementation

String secretMiddleString() {
  if (length >= 12) {
    String substring = this.substring(0, 8);
    String middleDots = '...';
    String lastFourChars = this.substring(length - 4);

    return '$substring$middleDots$lastFourChars';
  } else {
    return this;
  }
}